VueJs: Touch after modifying selection value in child component
P粉878542459
P粉878542459 2023-09-04 17:10:56
0
1
575
<p>I'm using VueJs and I have this child component in my parent component. When the selection of the child component changes, I need to trigger a function in the parent component. </p> <p><strong>Subcomponent:</strong></p> <pre class="brush:php;toolbar:false;">watch: { selectCoin() { this.$emit("currencyType", this.selectCoin["title"]); } }</pre> <p>The child component I use inside the <strong>parent component</strong>: </p> <pre class="brush:php;toolbar:false;"><app-select-coin @coin="body.value = $event" @currencyType="body.currencyType = $event" :data="body" /></pre> <p>When the child component responds to the $emit of the parent component, I need to call this method: </p> <pre class="brush:php;toolbar:false;">methods :{ myFunction() { } }</pre>
P粉878542459
P粉878542459

reply all(1)
P粉312631645

I successfully accomplished this by adding a function in the "v-on" of @currencyType and passing it the value received from the child component as a parameter.

<app-select-coin
  @coin="body.value = $event"
  @currencyType="myFunction(body.currencyType = $event)"
  :data="body"
/>
methods :{
   myFunction(ct) {

   }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!