小编Jak*_*zig的帖子

Vue3组合API查看存储值

我想通过在 Vue 组件中观察 Vuex 状态值来检测它的变化。我目前正在使用 Vue 3 和组合 API。我尝试过以下方法:

setup(props) {
   const store = useStore();

   watch(store.getters.myvalue, function() {
      console.log('value changes detected');
   });

   return {
      myvalue: computed(() => store.getters.myvalue)
   }
},
Run Code Online (Sandbox Code Playgroud)

但改变console.log()时不会被调用。myvalue

vue.js vuex vuejs3 vue-composition-api

16
推荐指数
2
解决办法
3万
查看次数

标签 统计

vue-composition-api ×1

vue.js ×1

vuejs3 ×1

vuex ×1