背景:
初学vue做练习项目的时候,基于vue2.0版本使用refs属性获取v-for循环的dom时出现获取不到dom的情况,尝试采用原生的方法出现同样的情况。查了很多资料没有找到对应的详细说明,现将我发现的一些问题分享给大家。
html部分
<div class="food-group" v-for="(item,index) in goods" :key="index" ref="group">
....
</div>
复制代码
定义的方法methods
methods: {
getHeightList() {
let height = 0;
this.heightList.push(height);
// let list = this.$refs