Ionic NavController canSwipeBack()方法在返回true时返回false

时间:2017-10-20 08:13:19

标签: cordova ionic-framework ionic3

我在离子页面中有这个代码:

ionViewDidLoad(){
console.log('swipeBackEnabled ' + this.navCtrl.swipeBackEnabled);
console.log('canGoBack ' + this.navCtrl.canGoBack());
console.log('canSwipeBack ' + this.navCtrl.canSwipeBack());

}

它返回true / true / false。

swipeEnabled的行为完全符合预期,因为它是在app.module.ts文件的App Config选项中设置的

但是返回true的canGoBack()表现得完全正常。页面本身通过navCtrl.push方法导航,实际上,它会在离子导航栏组件中渲染自动后退按钮。单击此按钮时,应用程序确实会返回。

canSwipeBack()返回false是我无法理解的,因为根据文档,如果canGoBack()和swipeBackEnabled为true,它应该返回true。情况确实如此。

我搜索整个项目,包括swipeBackEnabled的任何意外覆盖的编译文件为false,并且在项目的任何地方都不存在这样的事件。这是app config。

IonicModule.forRoot(
  MyApp, 
  {
    swipeBackEnabled: true,
    mode: 'ios',
    platforms: {
      ios: {
        swipeBackEnabled: true,
        statusbarPadding: false,
      },
      android: {
        swipeBackEnabled: true,
        mode: 'md'
      },
      core: {
        mode: 'ios',
        swipeBackEnabled: true,
      }
    }
  }
),

记录getViews()会返回以下内容

(2) [ViewController, ViewController]

0: ViewController {_isHidden: true, _state: 3, willEnter: EventEmitter, didEnter: EventEmitter, component: ƒ, …}

1: ViewController {_isHidden: false, _state: 3, willEnter: EventEmitter, didEnter: EventEmitter, component: ƒ, …}

我在Chrome浏览器中对此进行了测试,并且我已经多次重启服务器和浏览器。

试图解决这个问题几个星期!

0 个答案:

没有答案
相关问题