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

Advantages and Problems of XHTML CSS Website Design

XHTML is the standard website design language cur...

How to use Docker to build a development environment (Windows and Mac)

Table of contents 1. Benefits of using Docker 2. ...

CSS setting div background image implementation code

Adding background image control to a component re...

Javascript File and Blob Detailed Explanation

Table of contents File() grammar parameter Exampl...

nginx proxy_cache batch cache clearing script introduction

Preface: I used the official nginx proxy_cache as...

Common attacks on web front-ends and ways to prevent them

The security issues encountered in website front-...

React antd tabs switching causes repeated refresh of subcomponents

describe: When the Tabs component switches back a...

XHTML Web Page Tutorial

<br />This article is mainly to let beginner...

Introduction to scheduled tasks in Linux system

Table of contents 1. Customize plan tasks 2. Sync...

Vue custom components use event modifiers to step on the pit record

Preface Today, when I was using a self-written co...

Nginx proxy forwarding implementation code uploaded by Alibaba Cloud OSS

Preface Because the mini program upload requires ...

Vue shopping cart case study

Table of contents 1. Shopping cart example 2. Cod...

MySQL advanced learning index advantages and disadvantages and rules of use

1. Advantages and Disadvantages of Indexes Advant...