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 183 forks source link

add vbase-3-ts-setup-props-emits #119

Open moh1434 opened 1 year ago

moh1434 commented 1 year ago

This snippet make setup typescript script with props and emits.

<template>
  <div>

  </div>
</template>

<script setup lang="ts">
export interface Props {
  user?: string
}
const props = withDefaults(defineProps<Props>(), {
  user: 'foo'
})

const emits = defineEmits<{
  (e: 'update:user', newValue: string): void
}>()
const onClick = () => emits('update:user', 'bar');

//in parent component:
//  v-model:user="userParentVariable"
//OR:
//  :user="userParentVariable" @update:user="userParentVariable = event"

</script>

<style scoped>

</style>