import queryString from 'querystring';(插件 npm install querystring)
export function replaceState(data) {
if (data && window.history && window.history.replaceState) {
const parsed = queryString.parse(window.location.search.replace('?', ''));
Object.assign(parsed, data);
console.log(queryString, parsed, window.location.search, 66666);
const url = window.location.origin + window.location.pathname + '?' + queryString.stringify(parsed);
console.log(url);
window.history.replaceState(null, window.document.title, url);
}
}
问题:修复浏览任务开红包返回异常
修复:首页接口请求成功之后,把shareId 置 ''
if(GetQueryString('name')){ replaceState({'name':''}); }