解决ios微信浏览器内vue项目url地址不变的问题
作者:
放下手机出来嗨 | 来源:发表于
2019-07-11 11:23 被阅读0次
方法一
afterEach(to, from) {
const u = navigator.userAgent.toLowerCase()
if (u.indexOf('like mac os x') < 0 || u.match(/WebP/i) === 'webp') return
if (to.path !== global.location.pathname) {
location.assign(to.fullPath)
}
}
方法二
beforeEach(to, from, next) {
next()
var replaceUrl = window.location.href.split('#')[0] + '#' + to.path;
var index = 0; // 索引初始化
// 给replaceUrl拼接参数
for (var i in to.query) {
// 判断是否等于第一个参数
if (index === 0) {
// 拼接地址第一个参数,添加“?”号
replaceUrl += '?' + i + '=' + to.query[i]
} else {
// 拼接地址非第一个参数,添加“&”号
replaceUrl += '&' + i + '=' + to.query[i]
}
index++; // 索引++
}
window.location.replace(replaceUrl); // 重定向跳转
}
本文标题:解决ios微信浏览器内vue项目url地址不变的问题
本文链接:https://www.haomeiwen.com/subject/gnerkctx.html
网友评论