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 获取高度

posted @ 2017-11-22 14:40  潇影D  阅读(1185)  评论(0编辑  收藏  举报