使用 $refs

父组件

<template>
    <section class="dataList">
      <provincesDataList ref="provincesDataRef"/>
    </section>
</template>
<script lang="ts" setup>
import provincesDataList from "../provincesDataList.vue";
const provincesDataRef = ref()
// 调用子组件getDataListFn方法
provincesDataRef.value.getDataListFn()
</script>

子组件:

<script lang="ts" setup>
import { ref, defineExpose } from "vue";
const getDataListFn = async () => {
    // 方法体
}
defineExpose({
    getDataListFn
});
</script>
05-01 11:03