vue3 option API

private blog

Xu Xiaomo's Blog - Vegetable chicken blog direct train

The full version of the series of articles has more pictures. CSDN blog post pictures need to be uploaded manually, so there are fewer pictures in the article.

Series Article Directory

Front-end series of articles - Portal
Back-end series of articles - Portal



vue3 option API

Vue3 provides two grammars, one is called optional API; the other is called combined API.

The optional API is used in the same way as vue2: object-oriented development mode

Most of the content is the same as vue2:

interpolation expression

same instruction

methods

directives

mixins

computed

watch

The first 6 life cycle hook functions are the same.

Different places:

Creating a vue instance is not the same:

const {
    
    createApp} = Vue
const app = createApp({
    
    
    // data不一样,必须是函数
    data() {
    
    
        return {
    
    
            
        }
    }
})
// 没有el,只有mount
app.mount('el')

v-if and v-for have different priorities, v-for takes priority in vue2, and v-if takes priority in vue3

Vue3 canceled the filter filter

The hook function of the vue3 custom instruction is different, and the abbreviation is different

Vue2 abbreviation means: bind + update - button permission, can not be abbreviated, can only be done with inserted

The abbreviation of vue3 stands for: mounted and updated - button permissions can be used directly in abbreviation

The last two destroyed functions of the life cycle hook function:

​ beforeUnmount

​ unmounted

To manually destroy an instance, it must be:

app.unmount()

Note

A large number of pictures are missing in this blog post, which seriously affects the integrity of the content and the reading experience. For the full content, please go to my vegetable blog—— Xu Xiaomo's Blog

Guess you like

Origin blog.csdn.net/qq_60306931/article/details/130815194