添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am implementing vuex in my application with Vue 3 and typescript. I'm getting the following error when I call the function : [vuex] unknown action type: documentModule/deleteDocument

I'm going to leave some of the implemented code below in case someone knows how to tell me the error.

documet-module.ts

const state = {
    fileDto: FileDto
const mutations = {
    DELETE_DOCUMENT(state: any, payload: any) {
        return true;
const actions = {
    async deleteDocument({ commit }: any, id: number) {
        await itiHttpService.delete(API.documents + '/' + id, null).then((response: any) => {
            commit('DELETE_DOCUMENT', response.data)
const getters = {
const documentModule = {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
export default documentModule;

index.ts

export default createStore({
    modules: {
        documentModule

main.ts

const app = createApp(App);
const emitter = mitt();
app.use(router);
app.use(i18n);
app.use(store);
app.provide('emitter', emitter);
app.config.globalProperties.$appInfo = appInfo;
app.mount('#app');

document-list.ts

function deleteDocument() {
    const message: string = `¿Eliminar documento${((selectedRowKeys.value.length === 1) ? "" : "s")}?`;
    MessageService.confirm(message, null, async (res) => {
        if (res) {
            for (const element of selectedRowKeys.value) {
                store.dispatch('documentModule/deleteDocument', element);
            dataGrid.value.instance.refresh();

Please, I need someone to help me find the error.

What you're showing should work (demonstrated below). You didn't include the imports in your code but are you sure there isn't something wrong there?

const store = Vuex.createStore({
  modules: {
    documentModule: {
      namespaced: true,
      state: {
        fileDto: 'abcd'
      mutations: {
        DELETE_FILE(state, payload) {
          console.log('mutated');
          state.fileDto = null;
      actions: {
        deleteFile({
          commit
        }, id) {
          console.log('called!');
          commit('DELETE_FILE');
const app = Vue.createApp({});
app.use(store);
store.dispatch('documentModule/deleteFile');
<script src="https://unpkg.com/vue@3"></script>
<script src="https://unpkg.com/vuex@4"></script>
  <div id="#app"></div>
</body>
</html>

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.