看
//获取url中指定key的参数值 export const getQueryParam = (name, url = null) => { if (!url) url = window.location.search var q = url.match(new RegExp('[?&]' + name + '=([^&#]*)')) return (q && q[1]) || '' } //修改url中指定key的参数值 export const setQueryParam = (key, value, uri = null) => { uri = uri || window.location.href;//window.location.search.href var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i') var separator = uri.indexOf('?') !== -1 ? '&' : '?' if (uri.match(re)) { return uri.replace(re, '$1' + key + '=' + value + '$2') } else { return uri + separator + key + '=' + value } }