希望获取每一个子元素的高度
html
<div class="foods-wrapper" ref="foodsWrapper">
<ul>
<li v-for="item in goods" class="food-list food-list-hook">
<h1 class="title">{{item.name}}</h1>
</li>
</ul>
</div>
vue逻辑
mounted() {
this.$nextTick(() => {
this._calculateHeight()
})
},
methods: {
_calculateHeight() {
let foodList = this.$refs.foodsWrapper.getElementsByClassName('food-list-hook')
console.log(foodList)
console.log(foodList.length)// 0
}
_calculatrHeight中得到的foodList打印出来如下,length长度为9,但是并不能使用,打印foodList.Length长度为0,求指点
噜噜哒
梵蒂冈之花
相关分类