mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Fix child components data
This commit is contained in:
parent
2c4a512dda
commit
7f3a39fea1
@ -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>
|
||||
|
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user