Vue3设置动态ref

:ref="(el)=>setItemRef(el, 'test'+1)"
const iframeRefs = {}
const setItemRef = (el, key) => {
  if (el) {
    iframeRefs[key] = el
  }
}

onMounted(()=>{
  const iframeKey = 'test1'
  const iframe = iframeRefs[iframeKey]
  console.log(iframe)
})

猜你喜欢

转载自blog.csdn.net/SongZhengxing_/article/details/127366411
今日推荐