Business background
- Learning
nuxt
staticvue
Project - migrate a completed vue project to the nuxt framework
Perplexities encountered
- in
vue
, the definitionvuex
is an instance object defined directly
the code is as follows:
export default new Vuex.Store({
state: {
},
mutations: {
},
debug: true
});
- but in the
nuxt
official document, it is defined in this way
sample code is as follows:
const createStore = () => {
return new Vuex.Store({
state: {
},
mutations: {
}
})
}
question
-
nuxt
what is the reason for doing this? Instantiate objects only when called to save performance? - if I want to call the
store
object on another non-component page, don"t I have to re-instantiate it again?