Conversation

moh1434

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>

@moh1434moh1434 closed this Sep 5, 2023
@moh1434moh1434 reopened this Sep 5, 2023
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

@moh1434