代码实现:

import { ref, onMounted } from 'vue'const mains = ref()onMounted(() => {const height = mains.value.clientHeightconsole.log(height, 1234)}).search {width: 100px;height: 100px;margin: 0 auto;background-color: greenyellow;}

输出结果: