Uni-app life cycle finishing

Application life cycle

Detailed address: https://uniapp.dcloud.io/collocation/frame/lifecycle

Application life cycle can only be monitored in App.vue, monitoring on other pages is invalid.

function Description
onLaunch Triggered when uni-app initialization is complete (global trigger only once)
onShow When uni-app starts, or enter the foreground display from the background
onHide When uni-app enters the background from the foreground
onError Triggered when uni-app reports an error
onUniNViewMessage To monitor the data sent by the nvue page, please refer to nvue to vue communication
onUnhandledRejection Listener function for unprocessed Promise rejection event (2.8.1+)
onPageNotFound No monitoring function exists on the page
onThemeChange Monitor system theme changes

Page life cycle

Function name Description
onLoad Monitor page loading, the parameter is the data passed on the previous page, and the parameter type is Object (used for page parameter transfer)
onShow Monitor page display. It is triggered every time the page appears on the screen, including returning from the lower page point to reveal the current page
onReady The first rendering of the monitoring page is complete. Note that if the rendering speed is fast, it will be triggered before the page enters the animation.
onHide Monitor page hiding
onUnload Monitor page uninstall
onResize Monitor window size changes App, WeChat applet
onPullDownRefresh Monitor user pull-down actions, generally used for pull-down refresh
onReachBottom Event when the page scrolls to the bottom (not scroll-view to the bottom)
onTabItemTap Triggered when tab is clicked, the parameter is Object
onShareAppMessage The user clicks on the upper right corner to share
onPageScroll Monitor page scrolling, the parameter is Object
onNavigationBarButtonTap Listen to the native title bar button click event, the parameter is Object
onBackPress To monitor the page return, return event = {from:backbutton, navigateBack}, backbutton indicates that the source is the return button in the upper left corner or the android return key; navigateBack indicates that the source is uni.navigateBack; detailed description and usage: onBackPress in detail. The Alipay applet can only be triggered by the real machine and can only monitor the return caused by non-navigateBack, and cannot prevent the default behavior.
onNavigationBarSearchInputChanged Monitor the input content change event of the native title bar search input box
onNavigationBarSearchInputConfirmed Monitor the search event of the native title bar search input box, triggered when the user clicks the "search" button on the soft keyboard.
onNavigationBarSearchInputClicked Listen to the click event of the search input box in the native title bar
onShareTimeline Monitor users click on the upper right corner to forward to Moments
onAddToFavorites Listen for users to click favorites in the upper right corner

Component life cycle

Function name Description
beforeCreate Called after instance initialization
created It is called immediately after the instance is created.
beforeMount Called before the start of the mount.
mounted Called after mounting to the instance.
beforeUpdate Called when the data is updated, before the virtual DOM is patched.
updated The virtual DOM is re-rendered and patched due to data changes, after which the hook will be called.
beforeDestroy Called before the instance is destroyed. At this step, the instance is still fully available.
destroyed Called after the Vue instance is destroyed. After the call, everything indicated by the Vue instance will be unbound, all event listeners will be removed, and all child instances will be destroyed.

Guess you like

Origin blog.51cto.com/yzhipeng/2547305