思路emit 事件传入callback
子组件
<script setup>
const emit = defineEmits(['submit']);
const handleSubmit = () => {
emit('submit', (val: boolean) => {
if (!val) {
return false;
}
});
}
<script/>
<template>
<button @click="handleSubmit">
Click
</button>
<template/>
父组件
<script setup>
const verification = (callback) => {
callback(false)
}
<script/>
<template>
<ChildComponent @submit=(callback) => verification(callback) />
<template/>