<script setup>
import {
reactive,
toRef,
toRefs
} from 'vue'
const testObj = reactive({
a: 1,
b: 2,
});
const testObj2 = ref({
c: 3,
d: 4,
});
// toRefs 的使用
// const { a, b } = toRefs(testObj);
// const { c } = toRefs(testObj2.value);
// toRef 的使用
let a = toRef(testObj, "a");
let b = toRef(testObj, "b");
let c = toRef(testObj2.value, "c");
setTimeout(() => {
a.value = 666;
c.value = 888;
console.log("2s后");
}, 2000);
</script>
<template>
<div>
<div>{{ a }}-{{ b }}-{{ c }}</div>
</div>
</template>