【js】获取url query参数的方法

1
2
3
4
5
6
7
8
9
10
11
const getUrlParams = (url) => {
let str = url.split('?')[1]
let items = str.split('&')
let result = {};
let arr = [];
for (let i = 0; i < items.length; i++) {
arr = items[i].split('=');
result[arr[0]] = arr[1];
}
return result
}

本文作者: haise
本文地址https://www.shifeng1993.com/2017/08/06/js_urlParams/
版权声明: 转载请注明出处!