mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +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) => {
|
||||
if (typeof Component === 'function' && !Component.options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
@ -38,7 +38,10 @@ function loadAsyncComponents (to, ___, next) {
|
||||
}
|
||||
return Component
|
||||
})
|
||||
<%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %>
|
||||
this._hashChanged = (from.path === to.path)
|
||||
if (!this._hashChanged) {
|
||||
<%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %>
|
||||
}
|
||||
Promise.all(resolveComponents)
|
||||
.then(() => next())
|
||||
.catch((err) => {
|
||||
@ -49,6 +52,7 @@ function loadAsyncComponents (to, ___, next) {
|
||||
}
|
||||
|
||||
function render (to, from, next) {
|
||||
if (this._hashChanged) return next()
|
||||
let Components = getMatchedComponents(to)
|
||||
this._dateLastError = this.$options._nuxt.dateErr
|
||||
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
|
||||
// will not update the instance data, so we have to update $data ourselves
|
||||
function fixPrepatch (to, ___) {
|
||||
if (this._hashChanged) return
|
||||
Vue.nextTick(() => {
|
||||
let instances = getMatchedComponentsInstances(to)
|
||||
_lastComponentsFiles = instances.map((instance, i) => {
|
||||
|
Loading…
Reference in New Issue
Block a user