D
D
dicem2020-04-21 14:53:26
Vue.js
dicem, 2020-04-21 14:53:26

Why is the method from mapActions is undefined?

In the component I have the following:

import { mapActions, mapGetters } from 'vuex';
...
methods: {
        ...mapActions('modulename', [
            'createTopic',
        ]),
        submitForm() {
                this.createTopic({
                        name: this.createName,
                        url: this.url,
                        description: this.createDescription,
                        parentId: event.id,
                })
        }

in the vuex module:
import actions from './actions.js';

export default {
     namespaced: true,
     actions
}

In the Vuex root element:
import modulename from './module/';

export default {
modules: {
...
modulename,
...
}
}


What do I get
Error in v-on handler: "TypeError: this.createTopic(...) is undefined"

Why is this happening? And what with namespaces and without them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Alexandrov, 2020-04-22
@Toscha

Where is the createTopic action itself?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question