vue pass component value $ attrs, $ listeners

When there is a parent component A, subassembly B, component C, grandchildren

By value AB BC surely we should be very familiar with, to pass values ​​through props and $ emit and $ on

So pass values ​​between AC how to do it?

1, event.bus bus traditional values

2, vuex but using vuex by value of the project is not very large, very complex time seemed a bit overkill

Then how to do it? Here's what we have to say $ attrs and $ listeners, pay attention to $ attrs of type {[key: string]: string} $ listeners of type {[key: string]: Function | Array <Function>}

 

Component A (Component parent):

 

Component B (subcomponent):

 

Component C (grandson of components):

 

This achieves the transmission of the message value assembly A to the component C grandchildren, can obtain the value of the message in the component C,

Guess you like

Origin www.cnblogs.com/skzxcwebblogs/p/11355149.html