Answers for "vue 3 emit data"

6

vuejs emit

<!--
 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() {
    	Vue.$emit('send', 'Hello World');
      }
    }
</child>

<parent>
  <child @send="receive"></child>
    
    methods: {
      receive(childData) {
        console.log(childData); // "Hello World"
      }
    }
</parent>
Posted by: Guest on July-28-2021

Browse Popular Code Answers by Language