Fix child components data

This commit is contained in:
Sébastien Chopin 2016-12-12 21:12:44 +01:00
parent 2c4a512dda
commit 7f3a39fea1
2 changed files with 6 additions and 12 deletions

View File

@ -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
})
}
}
}
</script>

View File

@ -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])