共计 290 个字符,预计需要花费 1 分钟才能阅读完成。
export function urlAddParams(params) {
let str = '';
let keys = Object.keys(params);
let len = keys.length - 1;
keys.forEach((key, index) => {str += key + '=' + params[key] + (index < len ? '&' : '');
});
let {origin, pathname, search, hash} = window.location;
search = search === ''?'?': search +'&';
return origin + pathname + search + str + hash;
}
正文完
发表至: javascript
2021-08-12