我想在父文件中调用子组件方法,子组件由渲染函数创建。下面是我的代码
child.ts
export default {
setup(props) {
//...
const getCropper = () => {
return cropper
}
return () =>
// render function
h('div', { style: props.containerStyle }, [
])
}
父.ts
<template>
<child-node ref="child"></child-node>
</template>
<script>
export default defineComponent({
setup(){
const child =ref(null)
// call child method
child.value?.getCropper()
return { child }
}
})
</script>