⊗jsvuPmCmEP 66 of 72 menu

Event Parameters in Vue

It is possible to pass parameters to emitted events. Let's look at an example. Let's assume that the parent component function accepts parameters:

methods: { func(arg1, arg2) { console.log(arg1, arg2); } }

These parameters must be specified as parameters of the function $emit, after the event name:

methods: { handle() { this.$emit('show', 'xxx', 'yyy'); } }

Pass the following method from the parent component to the child:

methods: { func(name) { console.log(name); } }

Make a button in the component with the employee, when clicked, the employee's name will be transferred to the parent component.

Pass the following method from the parent component to the child:

methods: { func(name, salary) { console.log(name, salary); } }

Make a button in the employee component that, when clicked, will transfer the employee's name and salary to the parent component.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline