Life cycle classification
From component creation , data initialization , mounting , updating , and destruction , this is the so-called life cycle of a component. beforeCreate
createdIt is called after the instance has been created. At this step, the instance has completed the following configurations: data observation, property and method calculations, watch/event event callbacks, and completed data initialization, but el has not. However, the hanging stage has not started yet, and the $el property is not visible yet. This is a common life cycle because you can call methods in methods, change the data in data, and the changes can be reflected on the page through Vue's responsive binding, get the calculated properties in computed, etc. Usually we can pre-process the instance here beforeMount (before mounting)It is called before the hang starts, and the related render function is called for the first time (virtual DOM). The instance has completed the following configurations: compiling the template, generating html from the data in the data and the template, and completing the el and data initialization. Note that it has not yet been hung on the html to the page. mountedMounting is completed, that is, the HTML in the template is rendered to the HTML page. At this time, you can generally do some ajax operations, and mounted will only be executed once. beforeUpdateCalled before data is updated, before the virtual DOM is re-rendered and patched. Further changes to the state can be made in this hook without triggering an additional re-rendering process. updatedThis hook is only called when the virtual DOM is re-rendered and patched due to data changes. When called, the component DOM has been updated, so operations that depend on the DOM can be performed. However, in most cases, changing the state during this period should be avoided, as this may cause an infinite loop of updates. This hook is not called during server-side rendering. beforeDestroy Called before the instance is destroyed, the instance is still fully usable. destroyed Called after the instance is destroyed. After the call, all event listeners will be removed and all child instances will be destroyed. This hook is not called during server-side rendering. Execution order (diagram)This is the end of this article about the detailed explanation of the differences in the Vue life cycle. For more relevant Vue life cycle content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Analysis of mysql temporary table usage [query results can be stored in temporary tables]
>>: Analysis of centos6 method of deploying kafka project using docker
Table of contents 1. Basic environment configurat...
1. Linux installation (root user operation) 1. In...
Table of contents Preface: 1. Create index method...
You may encounter the following problems when ins...
Uninstall the old version of MySQL (skip this ste...
Sending emails using PHP's mail function The ...
Table of contents 1. Prototype 2. Prototype point...
MySQL UTF-8 encoding MySQL has supported UTF-8 si...
Table of contents Safe Mode Settings test 1. Upda...
Table of contents The first The second Native Js ...
Before introducing the GROUP BY and HAVING clause...
Table of contents Deploy httpd with docker contai...
Introduction As mentioned in the previous article...
HTML+CSS+JS imitates win10 brightness adjustment ...
Table of contents 1. JavaScript issues 2. Advanta...