1

我正在开发基于登录的应用程序。所以如果我从登录页面应用程序按下后退按钮必须退出

app.run(function($ionicPlatform, $state){
  $ionicPlatform.registerBackButtonAction(function (event) {
    if ( ($state.$current.name=="app.login") ||
         ($state.$current.name=="app.discussions")
        ){
            // H/W BACK button is disabled for these states (these views)
            // Do not go to the previous state (or view) for these states. 
            // Do nothing here to disable H/W back button.
        } else {
            // For all other states, the H/W BACK button is enabled
            navigator.app.backHistory();
        }
    }, 100);

})

现在我正在使用这段代码,但如果点击一次后退按钮就会触发。

4

1 回答 1

0

实际上,此代码在第一次触摸时触发,因为它打算这样做。
要管理第二次单击,您可以设置一个 500 毫秒的计时器,例如,使用布尔值,如果在此时间范围内再次单击按钮,则退出。否则,您重置布尔值。

于 2014-12-15T13:22:49.700 回答