1.父组件
<template>
<div>
<h1>父组件</h1>
<son @change-money="change"></son>
</div>
</template>
<script setup lang='ts'>
import son from "../son.vue";
const change = (data) => {
console.log('子组件传来的值', data);
}
</script>
<style lang='scss' scoped></style>
2.子组件
<template>
<div>
</div>
<button @click="changeParent">传值</button>
</template>
<script setup lang='ts'>
const emit = defineEmits(['change-money'])
const changeParent = () => {
emit('change-money', 2000)
}
</script>
<style lang='scss' scoped></style>