vue3 + vuex4 在单文件组件中如何使用mapActions 报错,求解!

单文件组件使用mapActions,报错了,该如何使用??

<script lang="ts" setup>
import {computed, onMounted, ref} from "vue";
import {mapActions} from "vuex";

const actions = mapActions(["onSetUserName", "geiMenu"]);
onMounted(() => {
    actions.onSetUserName("王五");
});
</script>

vue3 + vuex4 在单文件组件中如何使用mapActions

讨论数量: 2

使用 useStore, 然后 dispatch

Ref: next.vuex.vuejs.org/zh/guide/compo...

2年前 评论
1874 (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!