[Vuejs]-Using Emits in Vue 3

0๐Ÿ‘

โœ…

I would recommend using the composition api like this:

<script setup>
import { defineEmits } from "vue";
const emit = defineEmits(["emit1", "emit2"]);

const sendEmit1 = () => {
  emit("emit1");
};
const sendEmit2 = () => {
  emit("emit2");
};
</script>

<template>
  <button @click="sendEmit1">emit 1</button>
  <button @click="sendEmit2">emit 2</button>
</template>

<script>
export default {
  name: "HelloWorld",
};
</script>

Working example on codesandbox

Leave a comment