<Parent> </ Parent> // parent component
<Child> </ Child> // subassembly
Parent component is transmitted to the sub-assembly:
Static transfer (the parent component of dynamic change, sub-assemblies unchanged):
<Parent: id = 'id' > </ Parent> // binding parameters defined in the parent component and then add subassembly: export default { props: ['id'], }
Dynamic Transfer (parent component dynamically changing subassembly follow the change):
<Parent ref = "child"> </ Parent> // within parent components defined ref, is equivalent to adding a name for the subassembly refs The method defined in subassembly, reception parameters: childMethod(item){ this.item= item }, Then using the JS parent components: this. $ refs.child.childMethod (item) // The item argument to sub-assemblies
Transmitted to the parent sub-assembly components:
<Parent @ parentMethod = "parentMethod"> </ Parent> // define a method within parent components Add method in JS: parentMethod(item) { this.item = item } Then the subassembly JS: this. $ emit ( 'parentMethod', 'item') // this will 'item' string passed to the parent component this.item