Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification Advice on 'vemit-child' Snippet #114

Open
Wakotu opened this issue Aug 19, 2022 · 1 comment
Open

Modification Advice on 'vemit-child' Snippet #114

Wakotu opened this issue Aug 19, 2022 · 1 comment

Comments

@Wakotu
Copy link

Wakotu commented Aug 19, 2022

The original snippet was:

@change="emit('change', event.target.value)"

I guess you are trying to type $emit but the $ was recognized as a symbol for placeholder. You can use \\$ in the snippet body instead.

@itpropro
Copy link

itpropro commented Sep 5, 2022

This is correct syntax. In Vue 3 you can define emits with the defineEmits compiler macro. E.g.:

<script setup lang="ts">
const emit = defineEmits<{ (event: 'eventName', id: string): void }>()
</script>
<template>
  <button @click="emit('eventName', 'abc')" />
</template>

You can find more information here: https://vuejs.org/guide/typescript/composition-api.html#typing-component-emits
I would keep it this way, as $emit would probably only be used with the options API that is not the recommended default anymore with Vue 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants