mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
[store] fix
This commit is contained in:
parent
a1d94f4148
commit
05725d70e7
@ -13,7 +13,6 @@ let storeData = {}
|
|||||||
// Check if store/index.js exists
|
// Check if store/index.js exists
|
||||||
if (filenames.indexOf('./index.js') !== -1) {
|
if (filenames.indexOf('./index.js') !== -1) {
|
||||||
storeData = getModule('./index.js')
|
storeData = getModule('./index.js')
|
||||||
storeData.state = storeData.state() // Vuex Bug!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store modules
|
// Store modules
|
||||||
@ -34,12 +33,16 @@ for (let filename of filenames) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createStore
|
// createStore
|
||||||
export const createStore = storeData === 'function' ? storeData : () => new Vuex.Store(storeData)
|
export const createStore = storeData === 'function' ? storeData : () => {
|
||||||
|
return new Vuex.Store(Object.assign({}, storeData, {
|
||||||
|
state: storeData.state() // Vuex Bug!
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
// Dynamically require module
|
// Dynamically require module
|
||||||
function getModule (filename) {
|
function getModule (filename) {
|
||||||
const file = files(filename)
|
const file = files(filename)
|
||||||
const module = Object.assign({}, file.default || file)
|
const module = file.default || file
|
||||||
if (module.state && typeof module.state !== 'function') {
|
if (module.state && typeof module.state !== 'function') {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error('[nuxt] store state should be a function.')
|
console.error('[nuxt] store state should be a function.')
|
||||||
|
Loading…
Reference in New Issue
Block a user