Fix calling data on hash changes

This commit is contained in:
Sébastien Chopin 2017-01-29 07:49:36 +01:00
parent 5d5649e28d
commit 55003631fc

View File

@ -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
})
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) => {