Vue 通过什么属性获取 DOM 元素?
vue2
<template>
<div ref="targetDom"></div>
</template>
<script>
console.log(this.$refs.targetDom)
</script>
vue3
<template>
<div ref="targetDom"></div>
</template>
<script setup>
import { ref } from 'vue'
const targetDom = ref()
console.log(targetDom.value)
</script>
9 回答1.7k 阅读✓ 已解决
6 回答1.5k 阅读
3 回答1.4k 阅读✓ 已解决
4 回答1.3k 阅读✓ 已解决
3 回答1.1k 阅读
2 回答1.2k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
vue2.x
vue3.x