Application life cycle in uniapp

Speaking of the life cycle, friends who are familiar with Vue must be no strangers. The basic grammar of uniapp is based on vue, and the concept of life cycle is also preserved. However, the difference is that the life cycle of uniapp can be roughly divided into three types, namely application life cycle, page life cycle and component life cycle.

1. Application life cycle

The application-level life cycle can only take effect if it is monitored in App.vue, and templates are not allowed on this page, which means that html code cannot be written in App.vue.

1.1 onLaunch

The onLaunch life cycle function indicates this life cycle, which must be triggered after the application initialization is completed. That is to say, this life cycle function will only be executed once when the entire application is opened to run, and then to the end.

<script>
	export default {
   
    
    
		onLaunch() {
   
    
    
			console.log

Guess you like

Origin blog.csdn.net/weixin_46167462/article/details/130793041