this.platform.registerBackButtonAction(() => {
// code that is executed when the user pressed the back button
});
并替换为:
this.platform.ready().then(() => {
document.addEventListener("backbutton", () => {
// code that is executed when the user pressed the back button
});
});
1 回答
Update: 这是在dfac9dc中修复的
Related: how to integrate hardware back button into ionic4 navigation
这是在GitHub,Ionic Forums和Twitter上跟踪的
在有正式修复之前,您可以使用此解决方法:
请注意,如果您想再次取消订阅,则需要保存subscribe(...)的结果 .
Old answer: (截止日期为2018年4月)
对于corresponding Cordova call,
registerBackButtonAction
是just a wrapper .所以你可以把你的旧电话转到
registerBackButtonAction
:并替换为: