How can I use $emit correctly? #7571
Answered
by
oumoussa98
mbnoimi
asked this question in
Help/Questions
-
I use tab component as a parent component. It has Parent.vue <template>
<div>
<DxTabs
@item-click="$emit('groupClick', groupID)"
/>
</div>
</template>
<script setup lang="ts">
import DxTabs from "devextreme-vue/tabs";
import { ref } from "vue";
const groupID = ref(-1);
</script> Child.vue <script setup lang="ts">
import Child from "@/components/Parent.vue";
function currentGroup(index: any) {
console.log("group id from child:", index.itemIndex);
}
</script>
<template>
<main>
<Child
@group-click="currentGroup"
/>
</main>
</template> |
Beta Was this translation helpful? Give feedback.
Answered by
oumoussa98
Jan 24, 2023
Replies: 1 comment
-
Yes, the issue is related to <!-- Parent.vue -->
<template>
<div>
<DxTabs
@item-click="$emit('groupClick', $event)"
/>
</div>
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mbnoimi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, the issue is related to
$emit
functionYou need to pass the
$event
as a second argument like so