About the problem that WeChat Mini Programs wx:if will make the component life cycle execute many times.

because Mini Program"s router cannot display content in part of the page like vue-router, it is necessary to use eventbus when doing the bottom navigation bar, and Wechat wx:if, for the middle content, but wx:if will make the component"s hook function execute again. If wx:hidden, the front page loads too many interfaces, so how to solve


when using wx:hidden, you can pass a state into the component. For example, when there are four tab, switches, the tabId is passed to each component, and the component decides whether or not to do processing according to the current tabId. This prevents all component data from being loaded by default, but for the first time all components will definitely render

.
Menu