ionic 4防止/禁用设备硬件后退按钮 [英] ionic 4 prevent/disable device hardware backbutton
本文介绍了ionic 4防止/禁用设备硬件后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ionic 4项目中使用了角向布线(@ angular/router)来禁用ionic 4中的设备后退按钮prevent-default在我的代码中不起作用
I'm using angular routing(@angular/router) for ionic 4 project to disable the device back-button in ionic 4 prevent-default is not working below is my code in
app.component.ts
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);
}
});
});
我无法在此处禁用设备后退按钮的任何帮助
i am not able to disable the device back-button any help here
推荐答案
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();
});
}
这篇关于ionic 4防止/禁用设备硬件后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文