ionic5中在一个模态窗口中打开另一个,关闭后者之后出现的问题

发布时间 2023-04-28 09:55:05作者: johnjackson

几年前开发ionic时遇到的问题,当时在stackoverflow上找到的解决方案,记录下:

In @ionic/angular@5.0.0, when a modal layer is opened by modalController, and another modal layer is opened in it, and then the latter is closed, there will be a problem: a translucent mask layer will be displayed on the screen (backdrop). Upgraded to @ionic/angular@5.1.1, this problem was solved.

But in @ionic/angular@5.4.4(and @ionic/angular@5.1.1 ) there is another new problem: when opening another modal in one modal and closing the latter, ionic will push the componennt page of the second Modal into the navigation stack, the browser address has also changed. In the end, I can only solve it with the following code temporarily:

this.modalControll.dismiss().then(()=> this.navController.pop());

翻译:

@ionic/angular@5.0.0,当用modalController打开一个模态层,并在其中打开另一个模态图层,然后关闭后者时,会出现一个问题:屏幕(背景)上将显示半透明的遮罩层。升级到@ionic/angular@5.1.1,这个问题得到了解决。

但在@ionic/angular@5.4.4(和@ionic/angular@5.1.1 )中还有另一个新问题:当在一个模态中打开另一个模态并关闭后者时,ionic会将第二个模态的组件页推送到导航堆栈中,浏览器地址也发生了变化。最后,我只能暂时用以下代码来解决它:

 

this.modalControll.disse().then(() => this.navControll.pop());