mounted() {
if (window.history && window.history.pushState) {
// 向历史记录中插入了当前页
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goToBack, false);
}
},
destroyed() {
window.removeEventListener('popstate', this.goToBack, false);
},
methods: {
goToBack() {
sessionStorage.clear();
this.$closeCurrentApp({ jumpto: '/tab4' });// 去指定页面
history.pushState(null, null, document.URL);
},
},
以上就是vue 代码 监听安卓设备返回键 返回指定页面的代码
html 禁止手势返回:
//防止页面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});