- ref + 普通dom标签 获取真实dom对象
- ref + 组件标签 获取组件实例对象
setup() { const h1Ref = ref(null) const comRef = ref(null) onMounted(() => { console.log(h1Ref.value) console.log(comRef.value) }) // 必须return return { h1Ref, comRef } } } </script> 标签:vue,onMounted,comRef,h1Ref,null,ref,模板 From: https://www.cnblogs.com/96net/p/16756303.html