import { reactive, computed } from "vue"; export default { name: "HelloWorld", setup() { let person = reactive({ firstName: "李", lastName: "晓玲", }); //计算属性简写(没有考虑计算属性被修改被修改的情况) person.fullName = computed(() => { return person.firstName + person.lastName; }); //计算属性完整写法 /*person.fullName = computed(()=>{ get(){ return person.firstName + '-'+ person.lastName }, set(value){ const newName = value.split('-') person.firstName = newName[0] person.lastName = newName[1] } })*/ return { person, }; }, };