<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 获取高度
时间: 2024-10-11 00:25:25