Call store.replaceState when app is created

This commit is contained in:
Sébastien Chopin 2016-11-24 13:16:30 +01:00
parent 920e969da8
commit b2b707ae71

View File

@ -190,12 +190,6 @@ const NUXT = window.__NUXT__ || {}
if (!NUXT) {
throw new Error('[nuxt.js] cannot find the global variable __NUXT__, make sure the server is working.')
}
<% if (store) { %>
// Replace store state
if (NUXT.state) {
store.replaceState(NUXT.state)
}
<% } %>
// Get matched components
const path = getLocation(router.options.base)
const resolveComponents = flatMapComponents(router.match(path), (Component, _, match, key, index) => {
@ -244,6 +238,12 @@ Promise.all(resolveComponents)
window.onNuxtReady(_app)
}
}
<% if (store) { %>
// Replace store state
if (NUXT.state) {
store.replaceState(NUXT.state)
}
<% } %>
_app.setTransition = _app.$options._nuxt.setTransition.bind(_app)
if (Components.length) _app.setTransition(Components[0].options.transition)
_app.error = _app.$options._nuxt.error.bind(_app)