生命周期

vue,react,weapp 生命周期函数


小程序app.js 小程序page.js 小程序自定义组件生命周期 behaviors 同自定义组件
onLaunch (options)  onLoad (options)  created  
onShow (options)  onShow () 

attached

在组件实例进入页面节点树时执行

 
onHide ()  onReady ()  ready  
  onHide ()  moved  
onError ()  onUnload ()  detached  
       
    lifetimes里面优先级最高  
       
    pageLifetimes 父组件生命周期钩子  
    show、hide、resize  

https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html

https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/page.html

https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html

https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/route.html

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


vue2 vue3

    beforeCreate
    created


    beforeMount
    mounted


    beforeUpdate
    updated


    beforeDestroy
    destroyed ( unmounted)

setup :   没有created

 


    onBeforeMount
    onMounted


    onBeforeUpdate
    onUpdated


    onBeforeUnmount
    onUnmounted

ref      可在template中自动展开value

reactive    只读不可更改

readonly

computed

watch    

 ( 必须是响应式对象 / 返回一个响应式对象的函数

watchEffect  立即执行

errorCaptured

 onErrorCaptured  

 

 


 


 

 

 

。

posted @ 2021-12-01 10:58  Dz&Ying  阅读(81)  评论(0)    收藏  举报