Lifecycle Functions Life cycle functions are also called: life cycle callback functions, life cycle functions, life cycle hooks What is it: Vue helps us call some functions with special names at critical moments The name of the life cycle function cannot be changed, but the specific content of the function is written by the programmer according to the needs This in the lifecycle function refers to vm or component instantiation object Common life cycle hooks 1. 2. About Vue destroy instance: 1. After destruction, no information can be seen with the help of Vue developer tools 2. Custom events will become invalid after destruction, but native DOM events are still valid 3. Generally, data will not be operated in beforeDestory, because even if the data is operated, the update process will no longer be triggered. <div id="root"> <h2 :style="{opacity}"> Welcome to learn Vue's life cycle</h2> <button @click="stop">Click me to stop the change</button> </div> <script> Vue.config.productionTip = false; const vm = new Vue({ el: '#root', data: { opacity: 1, }, methods: { stop() { // clearInterval(this.timer) this.$destroy(); } }, //After Vue completes template parsing and puts the real initial DOM element into the page (mounting is complete), call mounted mounted() { this.timer = setInterval(() => { this.opacity -= 0.01; if (this.opacity <= 0) this.opacity = 1; }, 16) }, beforeDestroy() { console.log('vm is about to travel to the west'); clearInterval(this.timer) } }) </script> SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Nginx reverse proxy configuration to remove prefix case tutorial
>>: A brief discussion on several situations where adding indexes to MySQL does not take effect
Wildcard categories: %Percent wildcard: indicates...
This article example shares the specific code of ...
Table of contents 1. Redux 1.1. Store (librarian)...
Since Zabbix version 3.0, it has supported encryp...
need: Merge identical items of one field and sort...
Table of contents Understanding Prototypes Unders...
1. Use data from table A to update the content of...
①. How to use the alias (CNAME) record: In the do...
1. Environmental requirements 1. Docker 17 and ab...
Enable WSL Make sure the system is Windows 10 200...
First, what is box collapse? Elements that should...
The full name of SSH is Secure SHell. By using SS...
The development of Docker technology provides a m...
Password Mode PDO::__construct(): The server requ...
Preface What is a slow query and how to optimize ...