I'm using VueJs and i have this children component in my father component, i need to trigger a function in the parent component, when the change in the select of the child component is detected.
Children component:
watch: {
selectCoin() {
this.$emit("currencyType", this.selectCoin["title"]);
}
}
Children component in my Father Component:
<app-select-coin
@coin="body.value = $event"
@currencyType="body.currencyType = $event"
:data="body"
/>
I need to call this method when the child component responds to $emit for the parent component:
methods :{
myFunction() {
}
}
CodePudding user response:
I managed to do it by adding the function in the "v-on" in @currencyType, and passing as parameter the values i received from the children in "$emit".:
<app-select-coin
@coin="body.value = $event"
@currencyType="myFunction(body.currencyType = $event)"
:data="body"
/>
methods :{
myFunction(ct) {
}
}