Ionic 4替代platform.registerBackButtonAction [英] Ionic 4 alternative for platform.registerBackButtonAction

查看:2216
本文介绍了Ionic 4替代platform.registerBackButtonAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我环顾了Ionic 4的新平台,似乎已经从中删除了 registerBackButtonAction 功能。

I looked around the new platform for the Ionic 4, it seems like the registerBackButtonAction function was removed from it.

还有其他替代方法来处理Android硬件后退按钮吗?

Are there any other alternatives to handle the Android hardware back button?

推荐答案

相关:如何整合硬件返回按钮进入ionic4导航

更新:

相关的GitHub问题

this.platform.backButton.subscribe(() => {
  // code that is executed when the user pressed the back button
})






旧答案:(截至4个月前的过期)


Old answer: (out of date as of 4 months ago)

registerBackButtonAction 只是一个包装 for 相应的Cordova电话

所以你可以把你的旧电话转到 registerBackButtonAction

So you can just take your old call to registerBackButtonAction:

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
  });
});

这篇关于Ionic 4替代platform.registerBackButtonAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆