Ionic2:按下后退按钮时重新加载离子内容

Cod*_*ute 3 ionic-framework ionic2

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

div*_*hch 9

答案是正确的,然而,它已经过时了.这是更新的答案.

链接到生命周期只需向下滚动,你应该看到它.

例:

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


A. *_*azi 7

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

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

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

随着离子β8,生命周期事件改变了他们的名字.查看官方离子博客,了解生命周期事件的完整列表.