// 用vue3+ts实现父子组件声明,父子组件传值,子父组件传值,父组件获取子组件声明的方法,父组件修改(添加)子组件样式,并且灵活应用ref,reactive,toRaw,defineProps,defineEmits,defineExpose,以及ts声明字符串,数值,数组,对象类型
<template>
<div>
<box ref="getBox" :data="data" @getChildData="handleChild" />
<button @click="handleClick">点击获取ref调取子组件的方法</button>
</div>
</template>
<script setup lang='ts'>
import { reactive, ref } from 'vue'
import box from './box.vue'
let index = ref<number>(0)
// 父组件获取子组件的调用函数方法
const getBox = ref<InstanceType<typeof box>>()
const handleClick = () => {
// 获取子组件的方法名
let isFn = getBox.value?.handleSubmit()
if(!isFn){
console.log("获取到了")
}