我想在离子框架中控制“按硬件后退按钮”的事件 . 这是我的代码 . 为什么不起作用?谢谢
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.StatusBar) {
StatusBar.styleDefault();
}
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
event.stopPropagation();
alert("Stop");
}, 100);
});
})
我也尝试其他解决方案:
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
event.stopPropagation();
alert("Stop");
}, 100);
})
但它仍然无效
谢谢
2 回答
那正是你想要的 ? :
信用:mircobabini / Angular.Ionic.HardwareBackButtonManager.js https://gist.github.com/mircobabini/689955216a036544d594
在基于cordova的应用程序(Ionic)中,可以使用以下三种方法来覆盖硬件后退按钮 .
onHardwareBackButton
offHardwareBackButton
registerBackButtonAction
有关详细信息,请查看http://www.codeexpertz.com/blog/mobile/override-hardware-back-button-cordova-based-application-ionic