避免销毁页面并避免再次触发ngoninit Angular Ionic

发布于 2025-02-06 22:29:56 字数 418 浏览 3 评论 0原文

我有2页A页和第B页,我再次使用两次。

示例我的路线:

Page A -> Page B -> Page A (second) -> Page B (second)

或在真实应用中实现:

posting -> profile -> another posting -> another profile

The problem:

当从第B(第二)到A页(第二)向后导航时,没有问题。但是,当再次导航到B页面时,第B页再次触发ngoninit,当我检查该页面上的变量时,它是空的。因此,我得出结论,B被摧毁了。

问题:
如何避免销毁?我想要从第A页(第二页)导航到B页面时,没有更改,显示B条件与我之前打开的情况相同。

*信息:每个URL已经使用不同的参数

I have 2 pages, Page A and Page B, that i use again twice.

Example my route:

Page A -> Page B -> Page A (second) -> Page B (second)

Or implemented in real app:

posting -> profile -> another posting -> another profile

The problem:

When navigate backward from Page B (second) to Page A (second) there is no problem. But, when navigate back again to Page B, Page B trigger NgOnInit again and when i check the variables on that page, it is empty. So, i conclude Page B was destroyed.

Question:
How to avoid destroy? i want when navigate back from Page A (second) to Page B, there is no changed, showing the page B condition that same like i opened before.

*info : Every url already use different parameter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荆棘i 2025-02-13 22:29:57

我使用了离子路线(离子切除术),并同意导航在离子中正常工作。我的错误是当导航时,我使用了Angular Library的Location.Back(),没有使用Ionic的Defaulthref

I used ionic route (IonicRouteStrategy) and agree that navigation work fine in ionic. My mistake is when navigate back, i used location.back() from angular library, didn't use defaultHref from ionic

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文