mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
Replace store state the soonest possible
This commit is contained in:
parent
474f68e46e
commit
4034801fc9
@ -336,12 +336,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) => {
|
||||
|
@ -26,6 +26,12 @@ Vue.use(Meta, {
|
||||
})
|
||||
|
||||
if (process.browser) {
|
||||
<% if (store) { %>
|
||||
// Replace store state before calling plugins
|
||||
if (window.__NUXT__ && window.__NUXT__.state) {
|
||||
store.replaceState(window.__NUXT__.state)
|
||||
}
|
||||
<% } %>
|
||||
// window.onNuxtReady(() => console.log('Ready')) hook
|
||||
// Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
|
||||
window._nuxtReadyCbs = []
|
||||
|
Loading…
Reference in New Issue
Block a user