Between the traditional values assembly vue

According to the object classification:

First, the parent-child value between components pass

1. Use props and $ emit

2. ref subassembly incorporated in the method to obtain the subassembly by this. $ Refs.xxx. The method / value or values

3. The subassembly using this. $ Parent or the method to obtain the value of parent component

4. parent components using this. $ Children or the method to obtain the value of subassembly

 

Second, the traditional values ​​brothers assembly

1. eventBus as middleware, and then use the $ emit to throw an event, use the $ on to listen to events

Here we must note a few things:. A.bus $ emit in beforeDestroy go trigger

b.bus. $ on the use of the created or mounted, and the callback function using the arrow, pointing to solve this problem

c. Using bus in beforeDestroy in. $ off to destroy event

Detailed reference click on the link

 

Third, the multi-level nested components pass value

1.使用 v-bind = "$attrs" v-on = "$listeners"

详情参考点击链接

2. provide and inject

 

Fourth, the repeated use of multiple components, the entire project needed

1. vuex

 

Guess you like

Origin www.cnblogs.com/lanhuo666/p/11273128.html