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