定义多个组件,使用wx:if判断显示隐藏,为什么只有第一个组件触发了onshow?

小程序 文章 2021-01-27 13:41 453 0 全屏看文

AI助手支持GPT4.0

定义多个组件,使用wx:if判断显示隐藏,为什么只有第一个组件触发了onshow?Define multiple components, use wx:if to determine whether to show or hide, why only the first component triggers onshow?

定义多个组件,使用wx:if判断显示隐藏,为什么只有第一个组件触发了onshow?

定义多个组件,使用wx:if判断显示隐藏,为什么只有第一个组件触发了onshow,切换第二个组件没有触发第二个组件的onshow呢

Define multiple components and use Wx: if to judge whether the display is hidden. Why is Onshow triggered only by the first component and not triggered by switching the second component

回答:

brave:

这里的 show 生命周期,其实等价于 页面的 onShow 生命周期。因此,他只会在页面 onShow 时触发

99🇨🇳:好的,了解
blah blah blah:

组件的最重要的生命周期是 created attached detached。你在created的生命周期方法里执行初始化的事件

参考资料:https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/lifetimes.html

99🇨🇳:好的,感谢
默认²⁰²⁰:

当条件为真的时候才会渲染 只有渲染之后才会触发组件的onshow

-EOF-

AI助手支持GPT4.0