Before because of

Today, I met a requirement. After registration, the user entered the small program for the second time. If the user’s information was not perfect, a pop-up window would pop up, prompting the user to improve the information.

Implementation logic: I store a field again in the database, call the wx.login method in app.js, get the user information, assign the value again, and then get the variable again in appData in the ready function of the popover component for judgment.

And it turns out that popovers don’t pop over.

The life cycle

First let’s look at what the applets life cycle is:

App

  1. onLaunch
  2. onShow
  3. onHide

Page

  1. onLoad
  2. onShow
  3. onReady
  4. onHide
  5. onUnload

Component

  1. created
  2. attached
  3. ready
  4. moved
  5. detached

The way we think about it, the life cycle looks like this:

App (onLaunch) -> Page(onLoad) -> Component(ready)

But this is not the case. The loading order of the applet is as follows:

App.onlaunch -> app.onshow

Second, execute component.created -> component.attached

Then run page.onload -> page.onshow

Finally execute Component.ready -> page.onready

So when a page contains components, the component lifecycle (including pageLifetimes) always takes precedence over the page, and the Behaviors lifecycle takes precedence over the component lifecycle.

Finally, I used setInterval to fulfill the requirements.