diff --git a/examples/custom-routes/pages/users/_id.vue b/examples/custom-routes/pages/users/_id.vue index 63b5d6c73a..7151655af8 100644 --- a/examples/custom-routes/pages/users/_id.vue +++ b/examples/custom-routes/pages/users/_id.vue @@ -18,14 +18,6 @@ export default { .catch(() => { error({ message: 'User not found', statusCode: 404 }) }) - }, - watch: { - $route () { - return axios.get(`https://jsonplaceholder.typicode.com/users/${this.$route.params.id}`) - .then((res) => { - this.user = res.data - }) - } } } diff --git a/lib/app/client.js b/lib/app/client.js index a9a2c2cf2a..01e755d2f9 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -130,12 +130,14 @@ function fixPrepatch (to, ___) { return } Vue.nextTick(() => { - let RouterViewComponentFile = this.$nuxt._routerViewCache.default.__file - if (typeof this.$nuxt._routerViewCache.default === 'function') RouterViewComponentFile = this.$nuxt._routerViewCache.default.options.__file let instances = getMatchedComponentsInstances(to) - instances.forEach((instance, i) => { + instances.forEach((instance) => { if (!instance) return; - if (instance.constructor.options.__file === RouterViewComponentFile) { + 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) { let newData = instance.constructor.options.data() for (let key in newData) { Vue.set(instance.$data, key, newData[key])