【问题标题】:Ionic2: Reload the ion content when back button is pressedIonic2:按下后退按钮时重新加载离子含量
【发布时间】:2016-09-19 17:13:28
【问题描述】:

当按下返回按钮时,如何重新加载位于<ion-content> 标签下的内容?

【问题讨论】:

    标签: ionic-framework ionic2


    【解决方案1】:

    那里的答案是正确的,但是已经过时了。这是更新的答案。

    指向Life Cycle 的链接只需向下滚动即可看到。

    例子:

      ionViewWillEnter() {
             console.log('Runs when the page is about to enter and become the active page.');
      }
    

    【讨论】:

    • 也适用于Ionic 4
    【解决方案2】:

    只需在要返回的视图中使用View Lifecycle Hook,例如:

    onPageWillEnter() {
          // You can execute what you want here and it will be executed right before you enter the view
        }
    

    或者您在要离开的页面上使用生命周期挂钩,然后将 onPageWillEnter() 替换为 onPageWillLeave()

    在 ionic beta 8 中,生命周期事件更改了名称。查看official ionic blog 获取生命周期事件的完整列表。

    【讨论】:

      猜你喜欢
      • 2012-02-22
      • 2015-05-20
      • 2016-03-18
      • 2014-02-17
      • 1970-01-01
      • 2010-12-26
      • 2023-03-03
      • 2011-06-05
      • 2018-11-22
      相关资源
      最近更新 更多