(→개요) |
(→개요) |
||
2번째 줄: | 2번째 줄: | ||
;Vue.js defineEmits | ;Vue.js defineEmits | ||
==JavaScript== | |||
<syntaxhighlight lang='html'> | |||
<script setup> | |||
const props = defineProps({ | |||
foo: String | |||
}) | |||
const emit = defineEmits(['change', 'delete']) | |||
// setup code | |||
</script> | |||
</syntaxhighlight> | |||
==TypeScript== | |||
<syntaxhighlight lang='typescript'> | <syntaxhighlight lang='typescript'> | ||
const emit = defineEmits<{ | const emit = defineEmits<{ | ||
14번째 줄: | 27번째 줄: | ||
update: [value: string] | update: [value: string] | ||
}>() | }>() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
2023년 10월 31일 (화) 10:51 판
1 개요
- Vue.js defineEmits
2 JavaScript
html
Copy
<script setup>
const props = defineProps({
foo: String
})
const emit = defineEmits(['change', 'delete'])
// setup code
</script>
3 TypeScript
typescript
Copy
const emit = defineEmits<{
(e: 'change', id: number): void
(e: 'update', value: string): void
}>()
typescript
Copy
// 3.3+
const emit = defineEmits<{
change: [id: number]
update: [value: string]
}>()
4 같이 보기
5 참고
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.