//ionic中的生命周期函數
onPageLoaded(){ //page初始化時
console.log("page 1 : page loaded");
}
//在這里可以做頁面初始化的一些事情
onPageWillEnter(){ //page即將進入時
console.log("page 1 : page will enter");
}
onPageDidEnter(){ //page進入后
console.log("page 1 : page did enter");
}
onPageWillLeave(){ //page即將離開
console.log("page 1 : page will leave");
}
onPageDidLeave(){ //page離開后
console.log("page 1 : page did leave");
}
onPageWillUnload(){
//從DOM中移除時候執行的生命周期,不常用
console.log("")
}
onPageDidUnload(){
//DOM中移除執行完成的時候,不常用
}
ionic v2中新的周期函數
| Page Event | Description |
|---|---|
ionViewLoaded |
Runs when the page has loaded. This event only happens once per page being created and added to the DOM. If a page leaves but is cached, then this event will not fire again on a subsequent viewing. The ionViewLoaded event is good place to put your setup code for the page. |
ionViewWillEnter |
Runs when the page is about to enter and become the active page. |
ionViewDidEnter |
Runs when the page has fully entered and is now the active page. This event will fire, whether it was the first load or a cached page. |
ionViewWillLeave |
Runs when the page is about to leave and no longer be the active page. |
ionViewDidLeave |
Runs when the page has finished leaving and is no longer the active page. |
ionViewWillUnload |
Runs when the page is about to be destroyed and have its elements removed. |
ionViewDidUnload |
Runs after the page has been destroyed and its elements have been removed. |
