H5 history.pushState 在微信内修改url后点击用safari打开/复制链接是修改之前的页面...
生活随笔
收集整理的這篇文章主要介紹了
H5 history.pushState 在微信内修改url后点击用safari打开/复制链接是修改之前的页面...
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
解決方案:url參數(shù)增加隨機(jī)參數(shù)
function wxRefresh() {var replaceQueryParam = (param, newval, search) => { var regex = new RegExp('([?;&])' + param + '[^&;]*[;&]?'); var query = search.replace(regex, '$1').replace(/&$/, ''); return (query.length > 2 ? query + '&' : '?') + (newval ? param + '=' + newval : ''); }; window.location.replace(location.protocol + '//' + location.host + location.pathname + replaceQueryParam('_wxr_', new Date().getTime(), location.search) + location.hash); }; // 執(zhí)行 wxRefresh();優(yōu)化加入refresh,避免重復(fù)刷新 share(route) {var replaceQueryParam = (param, newval, search) => {var regex = new RegExp('([?;&])' + param + '[^&;]*[;&]?')var query = search.replace(regex, '$1').replace(/&$/, '')return ((query.length > 2 ? query + '&' : '?') +(newval ? param + '=' + newval : ''))}if (!route.query.refresh) {var chat = '&'if (!Object.keys(route.query).length) {chat = '?'}window.location.replace(location.protocol +'//' +location.host +location.pathname +replaceQueryParam('_wxr_', new Date().getTime(), location.search) +location.hash +chat + 'refresh=true')}}
?
轉(zhuǎn)載于:https://www.cnblogs.com/richard1015/p/8477869.html
總結(jié)
以上是生活随笔為你收集整理的H5 history.pushState 在微信内修改url后点击用safari打开/复制链接是修改之前的页面...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Codeforces 919 D Sub
- 下一篇: BZOJ1227 [SDOI2009]虔