与Vue2.x中computed配置功能一致

# 与Vue2.x中computed配置功能一致

写法

import {computed} from 'vue'

setup(){
    ...
//计算属性——简写
    let fullName = computed(()=>{
        return person.firstName + '-' + person.lastName
    })
    //计算属性——完整
    let fullName = computed({
        get(){
            return person.firstName + '-' + person.lastName
        },
        set(value){
            const nameArr = value.split('-')
            person.firstName = nameArr[0]
            person.lastName = nameArr[1]
        }
    })
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
最后更新于: 2022/3/25 07:58:56
강남역 4번 출구
Plastic / Fallin` Dild