我在Vue2中使用了Composition。您能告诉我如何使用composition访问mapState吗?我也想关注状态的变化。因此,我将不得不在设置函数中使用它(不仅仅是在返回中)。谢谢
发布于 2021-02-27 21:43:55
不支持Vuex贴图帮助器(还没有?)在Vue 2或Vue 3组合应用编程接口中,它们的这个proposal已经停止了一段时间。
您必须像在docs中一样手动创建一个计算
const item = computed(() => store.state.item);一个更完整的例子:
import { computed } from 'vue';
import { useStore } from 'vuex';
export default {
setup() {
const store = useStore();
const item = computed(() => store.state.item);
return {
item
};
}
}https://stackoverflow.com/questions/66396751
复制相似问题