主题
emit
基本使用
vue
<!-- script setup 中 -->
<script setup>
const emit = defineEmits(['update:modelValue']) // 不成文规定,一般取名为 emit
</script>
<!-- template 中 -->
<template>
<input @input="e => emit('update:modelValue', e.target.value)" />
<input @input="e => $emit('update:modelValue', e.target.value)" />
</template>