vue小程序ref和v-for结合使用得到ref数组的一些问题
项目中需要对每一个民宿里的每一个房间都需要popup弹出层来介绍每一个房间,房间数据都在一个接口(此民宿)上。
主要代码如下:
HTML:
<view v-for='(item,index) in roomDetail' :key='index'> <text @tap="togglePopup('bottom', 'popup',index)" >{{item.bedsDescription}}</text> <uni-popup :ref="`popup${index}`" :type="type" style="z-index: 99;"> //弹出层里的内容 </uni-popup> </view>
JS:
togglePopup(type, open,id) {
console.log(this.$refs) //主要还是自己看看refs里的东西来写,大家都不太一样
this.$refs[`popup${id}`][0].open()
}