Android 无法修改
IOS 做到和Android统一 (点击两次回到上一页面)
mounted() {
this.history = window.history.length;
if (window.history && window.history.pushState) {
window.history.pushState(null, "title", "");
window.addEventListener("popstate", this.reload, false);
}
},
methods: {
reload() {
let u = navigator.userAgent;
let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isIOS) {
if (this.history >= 3) {
window.history.go(-2);
} else if (this.history <= 2) {
window.history.go(-1);
}
}
},
},
deactivated() {
window.removeEventListener("popstate", this.reload, false);
},
获取浏览器history记录,
因授权后第一次进入本地sessionStorage存入了code,二次进入不授权,history.go() 回退不同
如有其他解决方式欢迎留言!