Comparison uniapp life cycle and life cycle and vue

### uni-app Application Lifecycle

### uni-app section of the page lifecycle

### vue Lifecycle

Contrast ### uni-app page life cycle and life cycle vue

###### page load load display → → → finished loading the page hide → page unload ###### uni-app page load onLoad: monitor page load → onShow: Listener page displays → onReady: listen first page rendering is complete → onHide: hidden listening page → onUnload: listener page unload ###### vue page load created: instance is created after execution → beforeMount: instance is executed → mounted before mounting: Mounting example after the completion of the implementation of → updated: execution after page → beforeDestroy updated: destruction before executing page

#### Based on the above comparison: Recommendations:

1、uni-app的页面生命周期仅在page页面有效,而单独封装的组件中【页面周期无效】,但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted

### uni-app lifecycle https://uniapp.dcloud.io/frame?id=%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f

### vue life cycle https://cn.vuejs.org/v2/guide/instance.html#%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5 % 9B% BE% E7% A4 % BA

Guess you like

Origin www.cnblogs.com/huihuihero/p/12665304.html