页面index.vue
<template>
<div>
<component-a v-bind:user-name="userName" />
</div>
</template>
<script>
import ComponentA from "./components/ComponentA.vue"
export default {
components: {ComponentA},
data() {
return {
userName: '张三'
}
}
}
</script>
组件 ComponentA.vue
<template>
<div>
<div class="">A中直接渲染:{{studentName}}</div>
<component-b v-bind:user-name="studentName"/>
</div>
</template>
<script>
import ComponentB from "./ComponentB.vue"
export default {
components: {ComponentB},
props: {
userName: {
required: true
}
},
data() {
console.log("组件A props", this.userName)
return {
viewReady: false,
studentName: this.userName
}
},
created(){
console.log("组件A data",this.studentName)
}
}
</script>
组件componentB.vue
<template>
<div>组件B中渲染:{{user.name}}</div>
</template>
<script>
export default {
props: {
userName: {
required: true
}
},
data() {
console.log("组件B",this.userName)
return {
user:{
name:this.userName
}
}
}
}
</script>
年少的张三丰 (作者)
好的,预计什么时候可以修复呢?基本上每天都会来看一下有无更新。
2024-05-23 09:50