(→개요) |
(→같이 보기) |
||
| (같은 사용자의 중간 판 2개는 보이지 않습니다) | |||
| 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> | ||
==같이 보기== | ==같이 보기== | ||
* [[Vue.js defineProps]] | * [[Vue.js defineProps]] | ||
* [[`defineEmits` is a compiler macro and no longer needs to be imported.]] | |||
==참고== | ==참고== | ||
2023년 11월 1일 (수) 10:38 기준 최신판
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
로그인하시면 댓글을 쓸 수 있습니다.