Static GitHub Issues

[1543] New to Nuxt question

prev: Get name router in server incorrect!
next: How to specify the default child node to display in nested routes?

I noticed that folder store is automagically loaded, my question is, how do I get the store object to use directly? I'm aware that methods like fetch, asyncData, and nuxtServerInit have access to commit, dispatch and the like, but how do I do this:

store.dispatch('action',data)

from within a component <script></script> tags but not necessary the exported methods?

for example, suppose I want to invoke an action from created, there is no { store } as there would be for asyncData.

export default {
  asyncData({store}) {
    // store is available here
  },
  created({store}) {
   // store is not available here
  }

Does it make sense to import store?

import { store } from '../store/index'

Seems like it should be unnecessary since this file is already imported (?)

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1374">#c1374</a>)</em></sub></div>