一、获取参数 const queryString = window.location.search 二、创建正则匹配 const reg = /[?&][^?&]+=[^?&]+/g 三、提取参数 const str= quesyString.match(reg) console.log(found(str)) function found(arg) { const res = {} // 存放数据列表 if(arg) { found.forEach(item => { let temp = item.substring(1).split('=') let key = temp[0] let val = temp[1] res[key] = val }) } return res } 四、测试 const testStr = 'http://127.0.0.1:8080?a=1&b=2&c=3' const foundStr = testStr.match(reg) // ['?a=1', '&b=2', '&c=3'] console.log(found(foundStr)) // {a: '1', b: '2', c: '3'}