uniapp 生命周期

317 阅读1分钟

App

App/H5                           微信小程序         

beforeCreate                      beforeCreate
watch                             watch
onLoad                            created
onShow                            beforeMount
                                  computed
created                           onLoad
beforeMount                       onShow
computed
onReady                           mounted
mounted                           onReady
 

综上

在uniapp中,尽量只使用 uniapp的钩子函数。

用onLoad 代替created 用onReady代替mounted,
onLoad中也能获取到this实例
watch 紧接着beforeCreate后面
computed 紧接着 beforeMount后面
watch 永远在created,onLoad之前
computed 永远在 mounted,onReady之前