mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
parent
cbbf6652cd
commit
0acfc78932
@ -595,13 +595,8 @@ function normalizeComponents (to, ___) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNextPage (to) {
|
<% if (features.layouts) { %>
|
||||||
// Hide error component if no error
|
function setLayoutForNextPage (to) {
|
||||||
if (this._hadError && this._dateLastError === this.$options.nuxt.dateErr) {
|
|
||||||
this.error()
|
|
||||||
}
|
|
||||||
|
|
||||||
<% if (features.layouts) { %>
|
|
||||||
// Set layout
|
// Set layout
|
||||||
let layout = this.$options.nuxt.err
|
let layout = this.$options.nuxt.err
|
||||||
? (NuxtError.options || NuxtError).layout
|
? (NuxtError.options || NuxtError).layout
|
||||||
@ -611,7 +606,14 @@ function showNextPage (to) {
|
|||||||
layout = layout(app.context)
|
layout = layout(app.context)
|
||||||
}
|
}
|
||||||
this.setLayout(layout)
|
this.setLayout(layout)
|
||||||
<% } %>
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
function checkForErrors (app) {
|
||||||
|
// Hide error component if no error
|
||||||
|
if (app._hadError && app._dateLastError === app.$options.nuxt.dateErr) {
|
||||||
|
app.error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When navigating on a different route but the same component is used, Vue.js
|
// When navigating on a different route but the same component is used, Vue.js
|
||||||
@ -647,7 +649,7 @@ function fixPrepatch (to, ___) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
showNextPage.call(this, to)
|
checkForErrors(this)
|
||||||
<% if (isDev) { %>
|
<% if (isDev) { %>
|
||||||
// Hot reloading
|
// Hot reloading
|
||||||
setTimeout(() => hotReloadAPI(this), 100)
|
setTimeout(() => hotReloadAPI(this), 100)
|
||||||
@ -826,6 +828,9 @@ async function mountApp (__app) {
|
|||||||
|
|
||||||
// Add afterEach router hooks
|
// Add afterEach router hooks
|
||||||
router.afterEach(normalizeComponents)
|
router.afterEach(normalizeComponents)
|
||||||
|
<% if (features.layouts) { %>
|
||||||
|
router.afterEach(setLayoutForNextPage.bind(_app))
|
||||||
|
<% } %>
|
||||||
router.afterEach(fixPrepatch.bind(_app))
|
router.afterEach(fixPrepatch.bind(_app))
|
||||||
|
|
||||||
// Listen for first Vue update
|
// Listen for first Vue update
|
||||||
@ -874,7 +879,8 @@ async function mountApp (__app) {
|
|||||||
// First render on client-side
|
// First render on client-side
|
||||||
const clientFirstMount = () => {
|
const clientFirstMount = () => {
|
||||||
normalizeComponents(router.currentRoute, router.currentRoute)
|
normalizeComponents(router.currentRoute, router.currentRoute)
|
||||||
showNextPage.call(_app, router.currentRoute)
|
setLayoutForNextPage.call(_app, router.currentRoute)
|
||||||
|
checkForErrors(_app)
|
||||||
// Don't call fixPrepatch.call(_app, router.currentRoute, router.currentRoute) since it's first render
|
// Don't call fixPrepatch.call(_app, router.currentRoute, router.currentRoute) since it's first render
|
||||||
mount()
|
mount()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user