diff --git a/lib/app/client.js b/lib/app/client.js index c938cd6abe..6cc5a5d6c9 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -142,18 +142,11 @@ function render (to, from, next) { // 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.$nuxt._routerViewCache || !this.$nuxt._routerViewCache.default) { - return - } Vue.nextTick(() => { let instances = getMatchedComponentsInstances(to) - instances.forEach((instance) => { + instances.forEach((instance, i) => { if (!instance) return; - let file = instance.$parent._routerViewCache.default.__file - if (typeof instance.$parent._routerViewCache.default === 'function') { - file = instance.$parent._routerViewCache.default.options.__file - } - if (instance.constructor.options.__file === file) { + if (_lastPaths[i] === instance.constructor._path) { let newData = instance.constructor.options.data() for (let key in newData) { Vue.set(instance.$data, key, newData[key])