Android 無法修改
IOS 做到和Android統(tǒng)一 (點擊兩次回到上一頁面)
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記錄,
因授權(quán)后第一次進(jìn)入本地sessionStorage存入了code逊桦,二次進(jìn)入不授權(quán)宁改,history.go() 回退不同
如有其他解決方式歡迎留言楔壤!