关于vuex4.0中useStore注意事项
不管在方法中还是setup中,对于useStore的使用,应该先赋值再使用
定义(赋值):
const $store = useStore();
使用:
$store.state.xxx、$store.getters.xxx
如果直接使用的话,有时候会出现一些问题,例如:
let a = computed(mapGetter['xxx'].xxx.bind({$store: useStore()}))
此时访问a的值有时候访问不到
不管在方法中还是setup中,对于useStore的使用,应该先赋值再使用
定义(赋值):
const $store = useStore();
使用:
$store.state.xxx、$store.getters.xxx
如果直接使用的话,有时候会出现一些问题,例如:
let a = computed(mapGetter['xxx'].xxx.bind({$store: useStore()}))
此时访问a的值有时候访问不到