vue3下ref和reactive在watch里的区别:
Vue 会自动解包 ref,所以可以直接 watch(count),不需要 watch(() => count.value)
1.ref 在 watch 里可以省略 .value:
const count = ref(0);
watch(count, (newValue) => {
console.log("Count changed:", newValue);
});
2.reactive 需要 watch 某个具体属性:
const state = reactive({ count: 0 });
watch(() => state.count, (newValue) => {
console.log("State.count changed:", newValue);
});
