Home

Issue: 2887

How to import external component with external store

[issue link]

Hi,

I have a custom node module, and I want to import a vue component from that module to my nuxt project. The external component has its own vuex store and will dispatch its own action. How should I import it to my nuxt project?

For the way I import it now, it will throw [vuex] unknown action type: external_action. I guess it’s because this action is not defined in current nuxt project.

The following code is part of the external component, by triggering toggleModalAuth(), it will dispatch action toggleModalAuth, which is defined in the custom module.

methods: {
toggleModalAuth() {
      if(util.jwtTokenIsHere()) {
        this.$store.dispatch('toggleModalIdentity', {
          value: !this.$store.state.modalIdentityIsShown
        })
      } else {
        this.$store.dispatch('toggleModalAuth', {
          value: !this.$store.state.modalAuthIsShown
        })
      }
    }
}

Any help would be appreciated!!

This question is available on Nuxt.js community (#c2509)