url参数转对象
urlToToObj = (url) => {
const obj = {};
if (url) {
const params = url.split('?')[1].split('&');
params.map(item => obj[item.split("=")[0]] = item.split("=")[1]);
}
return obj;
// {abc: '1', type: '2'}
}
对象转url
objToUrl = (obj) => {
const tempArray = [];
for (const item in obj) {
if (item) {
tempArray.push(`${item}=${obj[item]}`);
}
}
return `https://www.xxx.com/xxx?${tempArray.join('&')}`;
// https://www.xxx.com/xxx?abc=1&type=2
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。