简体   繁体   English

从弹出窗口导航到页面时,在ionic2中滚动被禁用

[英]scrolling in ionic2 is disabled when I navigate from a popover to a page

Ionic2 disables scrolling in a page if I'm navigating to it from a popover, the problem details is as follows: 如果我从弹出窗口导航到页面,则Ionic2将禁用页面滚动,问题详细信息如下:

I have 3 pages, one is timeline that has this code: 我有3页,其中一个是具有以下代码的时间轴:

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

as shown in the code timeline calls a popover: ItemList, which has this code: 如代码时间轴中所示,将调用一个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});
 }

as shown in the code, when a click event happens on an item in the popover, the showUserProfile function is called, it closes the popover(which I only added this line to check if the popover is the reason of the error), and then navigates to another page: UserProfilePage. 如代码中所示,当popover中的某个项目发生click事件时,将调用showUserProfile函数,它会关闭popover(我只添加了这一行来检查popover是否是错误原因),然后导航到另一个页面:UserProfilePage。

in UserProfile page, I have a scroller, which works fine in all cases except for this one when I navigate to UserProfilePage from the itemListPage popover. 在UserProfile页面中,我有一个滚动条,在我从itemListPage弹出窗口导航到UserProfilePage时,在所有情况下都可以正常工作。 In this case the scroller only works if I replaced the this.nav.push(UserProfilePage, { userToShow: user}); 在这种情况下,仅当我替换了this.nav.push(UserProfilePage,{userToShow:user})时,滚动条才起作用。

with

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

I'm not sure why this happens, and what can I do to fix it. 我不确定为什么会发生这种情况,以及如何解决该问题。 PS: I don't want to close the popover, I want the user to go back to it, I just added it to check the error reason. PS:我不想关闭弹出窗口,我希望用户返回到它,我只是添加了它以检查错误原因。

this.viewCtrl.dismiss(); this.viewCtrl.dismiss(); returns a promise, so the correct usage should be: 返回承诺,因此正确的用法应该是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM