vue3 监听vuex里的数据变化
import {computed,watch,} from 'vue';const getShowTask = computed(()=>{//返回的是ref对象return store.state.监听的字段;})watch(getShowTask, (newVal, oldVal) => {console.log('newVal, oldVal', newVal, oldVal)}
·
import {
computed,
watch,
} from 'vue';
const getShowTask = computed(()=>{
//返回的是ref对象
return store.state.监听的字段;
})
watch(getShowTask, (newVal, oldVal) => {
console.log('newVal, oldVal', newVal, oldVal)
}, {immediate:true,deep:true});
更多推荐
已为社区贡献2条内容
所有评论(0)