In-depth understanding of the life cycle comparison between Vue2 and Vue3

In-depth understanding of the life cycle comparison between Vue2 and Vue3

Cycle comparison

vue2 vue3
beforeCreate setup
created setup
beforeMount onBeforeMount
mounted onMounted
beforeUpdate onBeforeUpdate
updated onUpdated
activeted onActiveted
deactiveted onDeactiveted
beforeDestory onBeforeUnmount
destoryed onUnmounted

usage

The life cycle in vue2 is used as a function at the same level as data/methods, such as created() {}

data() {
    return {}
},
created() {
    ...
}

The life cycle setup in vue3 is in the outermost layer and does not need to be loaded on demand. Other life cycles must be loaded on demand to be used.

import { omMounted } from 'vue'
setup() {
    onMounted(() => { ... })
}

Summarize

This 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:
  • Commonplace talk about the life cycle of Vue
  • Detailed explanation of Vue3 life cycle hook function
  • A brief discussion on the life cycle of Vue
  • Detailed explanation of Vue life cycle
  • Let's talk about the Vue life cycle in detail
  • Let's learn about Vue's life cycle

<<:  How to smoothly go online after MySQL table partitioning

>>:  Example of using CSS to achieve floating effect when mouse moves over card

Recommend

HTML+CSS to achieve text folding special effects example

This article mainly introduces the example of rea...

Detailed explanation of Docker usage under CentOS8

1. Installation of Docker under CentOS8 curl http...

Research on the value of position attribute in CSS (summary)

The CSS position attribute specifies the element&...

Comparing Node.js and Deno

Table of contents Preface What is Deno? Compariso...

Define your own ajax function using JavaScript

Since the network requests initiated by native js...

How to build a redis cluster using docker

Table of contents 1. Create a redis docker base i...

What is BFC? How to clear floats using CSS pseudo elements

BFC Concept: The block formatting context is an i...

Implementation of Portals and Error Boundary Handling in React

Table of contents Portals Error Boundary Handling...

Pure CSS to achieve cool charging animation

Let’s take a look at what kind of charging animat...

Detailed explanation of the core concepts and basic usage of Vuex

Table of contents introduce start Install ① Direc...

Detailed explanation of how to create an array in JavaScript

Table of contents Creating Arrays in JavaScript U...