/** * 获取路径参数 * @returns {{}} */ function getQueryString() { let qs = location.search.substring(1), // 获取url中"?"符后的字串 args = {}, // 保存参数数据的对象 items = qs.length ? qs.split("&") : [], // 取得每一个参数项, item = null, len = items.length; for(let i = 0; i < len; i++) { item = items[i].split("="); let name = decodeURIComponent(item[0]), value = decodeURIComponent(item[1]); if(name) { args[name] = value; } } return args; } /** * 前往首页 */ function loginToIndexFn(loginToIndex=getQueryString()["loginToIndex"]){ window.location.assign(loginToIndex); }