-
Notifications
You must be signed in to change notification settings - Fork 0
Emitting from Child to Parent
RayVector edited this page Dec 15, 2020
·
2 revisions
(ThirdElement.js) - child of MainElement.js
methods = {
// emit method to parent, emitName should be like emit event in parent
doEmit: () => this.emit(emitName, emitData)
}
(MainElement.js) - parent of ThirdElement.js
childList = [
{
component: ThirdApp,
props: {
msg: () => this.data.childProp,
},
emitEvents: {
newEmit: emitData => {
this.changeData({ // update state from child by emit event
text: emitData,
})
},
},
},
]
(ThirdElement.js) - child of MainElement.js
methods = {
doEmit: () => {
this.emit('newEmit', `from data: ${this.data.emitMsg}, from props: ${this.props.msg}`)
},
}