Application of onShow() in Uniapp

Encounter problems:

When using some variables to make a judgment, the result will be the same as the previous one when the next judgment is used up. For example, after the first house in the access control is opened and you switch to another house, the returned result is the same as the first house.

Cause Analysis:

It is used to use the same variable for judgment, but after the first execution, the variable is not re-initialized, so that when the page is loaded for the second time, the displayed result is the same as the first time.

Solution:

In onShow(), through some parameters, it is judged whether the house has been switched when switching pages. If the house has not changed, there is no need to re-initialize variables when switching pages. If the house changes, the variable is reinitialized.

Summarize:

1. onShow() can be executed when the page is displayed, and can be used to properly initialize the parameters in the page.

2. When calling custom parameters for judgment, it is best to re-initialize after use.

Guess you like

Origin blog.csdn.net/qq_44980680/article/details/128492226