【问题标题】:scrolling in ionic2 is disabled when I navigate from a popover to a page当我从弹出窗口导航到页面时,在 ionic2 中的滚动被禁用
【发布时间】:2016-11-25 08:31:19
【问题描述】:

如果我从弹出窗口导航到 Ionic2 页面,Ionic2 会禁用滚动,问题详情如下:

我有 3 页,其中一页是包含此代码的时间线:

  let popover = Popover.create(ItemListPage, {items: data.data});
  this.nav.present(popover);

如代码时间线所示调用了一个popover:ItemList,里面有这样的代码:

close() {
   this.viewCtrl.dismiss();
 }

 showUserProfile(user){
   this.close(); //I added this line to check if the popover is the reason
   this.nav.push(UserProfilePage, { userToShow: user});
 }

如代码所示,当popover中的item发生点击事件时,会调用showUserProfile函数,关闭popover(我只添加了这一行来检查popover是否是错误的原因) ,然后导航到另一个页面:UserProfilePage。

在 UserProfile 页面中,我有一个滚动条,当我从 itemListPage 弹出框导航到 UserProfilePage 时,它​​在所有情况下都可以正常工作,除了这个。在这种情况下,滚动条仅在我更换 this.nav.push(UserProfilePage, { userToShow: user});

    this.nav.setRoot(UserProfilePage, { userToShow: user});

我不确定为什么会发生这种情况,我可以做些什么来解决它。 PS:我不想关闭弹窗,我想让用户回到它,我只是添加它来检查错误原因。

【问题讨论】:

标签: typescript angular ionic2


【解决方案1】:

this.viewCtrl.dismiss();返回一个承诺,所以正确的用法应该是:

close() {
   return this.viewCtrl.dismiss();
 }
 showUserProfile(user){
   this.close().then(data =>{
       this.nav.push(UserProfilePage, { userToShow: user});
   });
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-30
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多