vue 获取dom元素

<template>
  <div style="display: block;" ref="abc">
    <!-- ... -->
  </div>
</template>

<script>
export default {
  mounted: function () { // 此处不能用beforeMounte
    console.log(this.$refs.abc.style.cssText)
  }
}
</script>

输出结果是 display: block;

this.$refs.abc.getBoundingClientRect().height 获取高度

原文地址:https://www.cnblogs.com/handsome-jm/p/7879123.html