第一种写法
import { computed, toRefs, reactive } from "vue";
let person = reactive({ name: "老天师", age: 123, like: "雷法" });
const { name, age, like } = toRefs(person);
const names = computed(() => {
return `${age.value}岁的${name.value}熟练使用无敌的${like.value}`;
});
第二种写法
import { computed, toRefs, reactive } from "vue";
let person = reactive({ name: "老天师", age: 123, like: "雷法" });
const { name, age, like } = toRefs(person);
const names = computed({
get() {
return `${age.value}岁的${name.value}熟练使用无敌的${like.value}`;
},
set() {
`${age.value}岁的${name.value}熟练使用无敌的${like.value}`;
},
});