Ionic2:按下后退按钮时重新加载离子内容
Ionic2: Reload the ion content when back button is pressed
如何在按下后退按钮时重新加载位于 <ion-content>
标签下的内容?
只需在要返回的视图中使用 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 以获取生命周期事件的完整列表。
那里的答案是正确的,但是已经过时了。这是更新后的答案。
Link 到 Life Cycle 只需向下滚动,您应该会看到它。
示例:
ionViewWillEnter() {
console.log('Runs when the page is about to enter and become the active page.');
}
如何在按下后退按钮时重新加载位于 <ion-content>
标签下的内容?
只需在要返回的视图中使用 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 以获取生命周期事件的完整列表。
那里的答案是正确的,但是已经过时了。这是更新后的答案。
Link 到 Life Cycle 只需向下滚动,您应该会看到它。
示例:
ionViewWillEnter() {
console.log('Runs when the page is about to enter and become the active page.');
}