因?yàn)槲业捻?xiàng)目不是嵌套在APP中的,所以出現(xiàn)了在APP中瀏覽器默認(rèn)帶前后返回鍵的情況。 所以在App.vue中添加了這個(gè)方法后,生效
mounted () {
if (window.history && window.history.pushState) {
// 向歷史記錄中插入了當(dāng)前頁(yè)
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goBack, false);
}
},
destroyed () {
window.removeEventListener('popstate', this.goBack, false);
},
methods: {
goBack () {
// console.log("點(diǎn)擊了瀏覽器的返回按鈕");
history.pushState(null, null, document.URL);
},
}
其余相關(guān)資料 https://blog.csdn.net/qq_32462903/article/details/90084887