mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
Fix calling data on hash changes
This commit is contained in:
parent
5d5649e28d
commit
55003631fc
@ -18,7 +18,7 @@ function mapTransitions(Components, to, from) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAsyncComponents (to, ___, next) {
|
function loadAsyncComponents (to, from, next) {
|
||||||
const resolveComponents = flatMapComponents(to, (Component, _, match, key) => {
|
const resolveComponents = flatMapComponents(to, (Component, _, match, key) => {
|
||||||
if (typeof Component === 'function' && !Component.options) {
|
if (typeof Component === 'function' && !Component.options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
@ -38,7 +38,10 @@ function loadAsyncComponents (to, ___, next) {
|
|||||||
}
|
}
|
||||||
return Component
|
return Component
|
||||||
})
|
})
|
||||||
|
this._hashChanged = (from.path === to.path)
|
||||||
|
if (!this._hashChanged) {
|
||||||
<%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %>
|
<%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %>
|
||||||
|
}
|
||||||
Promise.all(resolveComponents)
|
Promise.all(resolveComponents)
|
||||||
.then(() => next())
|
.then(() => next())
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -49,6 +52,7 @@ function loadAsyncComponents (to, ___, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function render (to, from, next) {
|
function render (to, from, next) {
|
||||||
|
if (this._hashChanged) return next()
|
||||||
let Components = getMatchedComponents(to)
|
let Components = getMatchedComponents(to)
|
||||||
this._dateLastError = this.$options._nuxt.dateErr
|
this._dateLastError = this.$options._nuxt.dateErr
|
||||||
this._hadError = !!this.$options._nuxt.err
|
this._hadError = !!this.$options._nuxt.err
|
||||||
@ -166,6 +170,7 @@ function normalizeComponents (to, ___) {
|
|||||||
// 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
|
||||||
// will not update the instance data, so we have to update $data ourselves
|
// will not update the instance data, so we have to update $data ourselves
|
||||||
function fixPrepatch (to, ___) {
|
function fixPrepatch (to, ___) {
|
||||||
|
if (this._hashChanged) return
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
let instances = getMatchedComponentsInstances(to)
|
let instances = getMatchedComponentsInstances(to)
|
||||||
_lastComponentsFiles = instances.map((instance, i) => {
|
_lastComponentsFiles = instances.map((instance, i) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user