Answer the question
In order to leave comments, you need to log in
How to import a store into an external file?
Nuxt uses and recommends the Vuex model system
// store/index.js
export const state = () => ({
counter: 0
})
export const mutations = {
increment (state) {
state.counter++
}
}
import store from '@/store'
"export 'default' (imported as 'store') was not found in '@/store'
Answer the question
In order to leave comments, you need to log in
I will say that unfortunately you can’t do without crutches, because. this is not specifically provided by nuxt itself. There are a couple of such solutions:
adin
two
The first one is from the nuxt developer himself, such a solution.
The second one is more or less.
I recommend designing the application correctly from a nuxt point of view, and not trying to do things that the framework doesn't provide.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question