import {computed} from 'vue'
setup(){
const person = reactive({
firstName:'',
lastName:''
})
// 计算属性-简写(只读不可改)
person.fullName = computed(()=>{
return person.firstName + '-' person.lastName
})
// 计算属性-完整写法(可读可修改)
person.fullName = computed({
get(){
return ...
}
set(value){
doSomething
}
})
}
Vue3 computed写法
最新推荐文章于 2024-05-13 17:58:23 发布