current position:Home>How does Vue transfer the data from the parent component to the child component intact?

How does Vue transfer the data from the parent component to the child component intact?

2022-04-29 18:52:21segmentfault

Now there is A、B、C Three components , Nesting with each other , Form father and son and grandchildren .
Now I want to put A The data transmitted by the component is transmitted to C, How to do ?
( Don't want to use props The reason is that A I didn't write the component , I can't control )

// A.vue
<div>
   <b  :name="1"  :data="[1,2,3]"></b>
</div>

// B.vue
<div>
   <c ...$attrs></c>  //  How to leave it intact A The data from the component is transmitted to c ...$attrs It should be the wrong way of writing 
</div>



Take the answer 1:

Then you can consider using provide/inject, Put this property in the parent component provide, Then inject... Into the sub component .



Other answers 1:

Then you can consider using provide/inject, Put this property in the parent component provide, Then inject... Into the sub component .

copyright notice
author[segmentfault],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291314270796.html

Random recommended