Open
Description
<script setup lang="ts">
import { shallowRef, watch } from "vue"
const state = shallowRef({ count: 1 })
// 回调没被触发
watch(state, () => {
console.log("State.count Updated")
}, { deep: true })
/**
* 修改以下代码使watch回调被触发
*
*/
// 方法1
state.value = {count: 2};
// 方法 2
state.value.count = 2;
triggerRef(state);
</script>
<template>
<div>
<p>
{{ state.count }}
</p>
</div>
</template>