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()
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM