不管在方法中还是setup中,对于useStore的使用,应该先赋值再使用
定义(赋值):
const $store = useStore();
使用:
$store.state.xxx、$store.getters.xxx
如果直接使用的话,有时候会出现一些问题,例如:
let a = computed(mapGetter['xxx'].xxx.bind({$store: useStore()}))
此时访问a的值有时候访问不到
博客园 © 2004-2026 浙公网安备 33010602011771号 浙ICP备2021040463号-3