vue3获取动态的dom的方法

203 阅读1分钟
   <child1 ref="aa"/>
   <child1=2 ref="bb"/>
 import { getCurrentInstance } from 'vue'
 //获取实例
 const { proxy } = getCurrentInstance()
 //动态的dom变量
 const fileRef = ref(null)
 //调用子组件的方法
  proxy.$refs[fileRef.value].init(fileUrl.value)