Vue3 (for personal use in notes)

Table of contents

1. What are the advantages of Vue3 over Vue2?

2. What is the difference between the life cycle of Vue3 and Vue2?

3. Composition API vs. Options API

3.1 What does the Composition API bring?

3.2 How to choose Composition API and Options API?

3.3 Do not misunderstand the Composition API


1. What are the advantages of Vue3 over Vue2?

  • better performance
  • smaller size
  • Better ts support (Vue3 is developed by ts)
  • better code organization
  • better logic extraction
  • more new features

2. What is the difference between the life cycle of Vue3 and Vue2?

  • beforeDestory changed to beforeUnmount
  • destroyed to unmounted
  • Others follow the life cycle of Vue2 

3. Composition API vs. Options API

3.1 What does the Composition API bring?

  • better code organization
  • Better logic reuse (how?)
  • better type inference

3.2 How to choose Composition API and Options API?

  • Sharing is not recommended, it will cause confusion
  •  Small projects, simple business logic, using Options API
  • For medium and large projects with complex logic, use Composition API

3.3 Do not misunderstand the Composition API

  •  Composition API is an advanced skill, not a basic skill
  • Composition API is designed to solve complex business logic
  • The Composition API is what Hooks are to React

Guess you like

Origin blog.csdn.net/weixin_39763711/article/details/126586813