sdras / vue-vscode-snippets

These snippets were built to supercharge my workflow in the most seamless manner possible.
https://marketplace.visualstudio.com/items?itemName=sdras.vue-vscode-snippets
MIT License
1.33k stars 185 forks source link

Modification Advice on 'vemit-child' Snippet #114

Open Wakotu opened 2 years ago

Wakotu commented 2 years ago

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 commented 2 years ago

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.