实例方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const getQueryString = name => {
var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
if (result == null || result.length < 1) {
return "";
}
return result[1];
}

JSON.stringify({
asd: '123',
qwe: '789',
zxc: '356'
}).replace(/:/g, "=").replace(/"/g, "").replace(/,/g, "&").match(/\{([^)]*)\}/)[1]
// 'asd=123&qwe=789&zxc=356'