您可以在此处找到有关Ionic 2 中查看生命周期挂钩的更多信息
Ionic 将一组视图生命周期钩子打包到 NavController 中。它们遵循四种事件处理程序模式:
1. onPageLoaded works the same way as ngOnInit
2. onPageWillEnter and onPageDidEnter are hooks that are available before and after the page in question becomes active
3. onPageWillLeave and onPageDidLeave are hooks that are available before and after the page leaves the viewport
4. onPageWillUnload and onPageDidUnload are hooks that are available before and after the page is removed from the DOM
就您而言,我认为您正在寻找的是onPageWillEnter
=============
编辑:
在 Ionic 2.0.0-beta.8 (2016-06-06) 上,Ionic Lifecycle Events 被重命名:
onPageLoaded renamed to ionViewLoaded
onPageWillEnter renamed to ionViewWillEnter
onPageDidEnter renamed to ionViewDidEnter
onPageWillLeave renamed to ionViewWillLeave
onPageDidLeave renamed to ionViewDidLeave
onPageWillUnload renamed to ionViewWillUnload
onPageDidUnload renamed to ionViewDidUnload
所以你需要使用的是:ionViewWillEnter