Last active
December 21, 2021 11:46
-
-
Save zdimaz/de872396de45b0f474e36e020fd9d0f2 to your computer and use it in GitHub Desktop.
emits vue 3 js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
From the child component, you want to do an "emit". | |
This tells the parent to run the callback specified | |
in the child component reference. Psuedo code: | |
--> | |
<child> | |
<button @click="send()">Click Me</button> | |
methods: { | |
send() { | |
this.$('send', 'Hello World'); | |
} | |
} | |
</child> | |
<parent> | |
<child @send="receive"></child> | |
methods: { | |
receive(childData) { | |
console.log(childData); // "Hello World" | |
} | |
} | |
</parent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
From the child component, you want to do an "emit". | |
This tells the parent to run the callback specified | |
in the child component reference. Psuedo code: | |
--> | |
<child> | |
<button @click="send()">Click Me</button> | |
methods: { | |
send() { | |
this.$('send', 'Hello World'); | |
} | |
} | |
</child> | |
<parent> | |
<child @send="receive"></child> | |
methods: { | |
receive(childData) { | |
console.log(childData); // "Hello World" | |
} | |
} | |
</parent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment