获取url参数值(可解码中文值)
/** * 根据指定参数名称获取参数值 * @param {String} urlStr 参数名称 * @return {Object} 参数值 * */ getUrlParams = function (urlStr) { // 获取url中"?"符后的字串 let url = urlStr || location.href; let params = {}; if (url.indexOf('?') != -1) { let str = url.substr(url.indexOf('?') + 1); let strs = str.split('&'); for (let i = 0; i < strs.length; i++) { params[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]); } } return params; };