Skip to content

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

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

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

wants to merge 2 commits into from

Conversation

moh1434
Copy link

@moh1434 moh1434 commented Feb 22, 2023

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>

@moh1434 moh1434 closed this Sep 5, 2023
@moh1434 moh1434 reopened this Sep 5, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant