我正在为 ionic 4 项目使用 Angular 路由(@angular/router)来禁用 ionic 4 中的设备后退按钮,防止默认不起作用,下面是我的代码
app.component.ts
this.platform.backButton.subscribe(() => {
if (this.router.url === '/Login') {
this.util.presentAppExitAlert();
} else {
// event.preventDefault();
console.log("invoing url ", this.router.url);
}
});
});
我无法在此处禁用设备后退按钮任何帮助
最佳答案
initializeApp() {
this.platform.ready().then(() => {
this.platform.backButton.subscribeWithPriority(9999, () => {
document.addEventListener('backbutton', function (event) {
event.preventDefault();
event.stopPropagation();
console.log('hello');
}, false);
});
this.statusBar.styleDefault();
});
}
关于angular - ionic 4 防止/禁用设备硬件后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55274992/