ionic3 lifecycle hook

ionViewDidLoad

Page loaded trigger, where the "loaded" refers to the resources required page has finished loading, but did not enter the state of this page (or the user sees on a page).

Note that it is a very playfully hooks, the whole is only called once, to be called when that is the first time to enter the page, then you have it, no matter how desolate and out desolately sad no longer care for you . Unless you put it in the background killed, re-enter the software (when pressing refresh the page for debugging is also possible).

Therefore, this hook for you to do some one-time processing, such as pulling the user data stored in the cache from the server.

ionViewWillEnter

Understand the literal meaning is "I want to come in" at the moment, this time the page is just beginning to switch. You can preprocess the data page at this time, this hook is called every time

ionViewDidEnter

When this hook is triggered, the user has entered a new page (page is active), it is also invoked every time.

Having said that I have to interject, ionic named on the hook for the majority of Chinese students is really friendly and ah, a will did put a thing resolved. Unlike some outside the framework of flirtatious (by mistake), and a bunch of ready, update, complied, destory or something, remember a forgotten time. (Of course, this is a joke, with the operating mechanism named frame components are closely related)

ionViewWillLeave

Page ready (is about to) leave the trigger, then the user has just triggered the return button or related events.

ionViewDidLeave

Page has (has finished) leaving the trigger, the page is inactive.

ionViewWillUnload

Page resource is about to be destroyed when triggered, now would you guess the hook and ionViewDidLoad, as it will only be triggered once?

Note: The
constructor is triggered before ionViewDidLoad
ionViewDidLoad trigger only the first time you enter the page
ionViewWillUnload will fire every time leaving the page

Guard hook

ionViewCanEnter

ionViewCanLeave < big column  ionic3 lifecycle hook / h2>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

ionViewCanEnter (): boolean { IF ( new new a Date () .getHours ()> = 8 ) { Console .log ( 'how do you look at what time it is, Why do not you so comfortable at home and then sleep na, give me standing outside to '! ); return to false ; } return to true ; }







// Xing Hua Lou attitude of thousands of pimps
ionViewCanLeave (): boolean { IF ( new new a Date () .getHours ()> = 22 ) { Console .log ( 'Damn son, you see, are so late, recently out of the wind so tight, it is better we stay right here, you see you girls are reluctant to go back to it ' ); return false ; } return to true ; }






to sum up

ionViewDidLoad first call returns void
ionViewWillEnter each call to return void
ionViewDidEnter each call to return void
ionViewWillLeave each call to return void
ionViewDidLeave each call to return void
ionViewWillUnload each call to return void
ionViewCanEnter Each call returns a boolean
ionViewCanLeave Each call returns a boolean

Guess you like

Origin www.cnblogs.com/lijianming180/p/12032185.html