离子后退按钮

Dev*_*Wol 6 android angularjs ionic-framework ionic

我有基本的离子应用程序,我已经禁用了应用程序上的后退按钮,是否有一个原因,后退按钮仍然在Android设备上工作?

我目前正在测试离子视图.

这是我的代码:

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
  $ionicPlatform.registerBackButtonAction(function(e) {
  e.preventDefault();
  }, 101);
})
Run Code Online (Sandbox Code Playgroud)

小智 5

根据离子文献

您的后退按钮操作将覆盖上述每个优先级低于您提供的优先级的操作.

并且鉴于您希望在所有情况下完全禁用后退按钮,并且引用列表中的操作的最高优先级为500,您应该提供超过500,600的优先级值.放置在$ ionicPlatform.ready()中时,下面的代码应该可以工作

 $ionicPlatform.registerBackButtonAction(function(e) {}, 600);
Run Code Online (Sandbox Code Playgroud)