代码: 遍历 modelList 数组套数组
<view class='modelitem' wx:for="{{modelList}}" data-order='{{item.name}}' wx:key> <view class='modelitemTitle' bindtap='modelitemTitle' data-index="{{index}}">{{item.name}}</view> <block wx:if="{{item.shows}}"> <view class='modelitem_item' bindtap='modelitem_item' data-name='{{itemTwo.name}}' data-model='{{itemTwo.id}}' wx:for="{{item.shopTruckModelEntityList}}" wx:key wx:for-item="itemTwo"> {{itemTwo.name}} </view> </block> </view>
//小知识:(获取自定义属性)
modelitemTitle(e){
console.log(e.currentTarget.dataset.index
}
区分 vue自定义属性
<ul class="homeList">
<li v-for="(item, index) of homeList"
:key="index"
:id="item.id"
@click="homeListClick(index,item.id)"
:class="{ 'bgcTwo': item.type!=1, 'bgcOneSelected': item.type==1&&(homeTicketIndex==index), 'bgcTwoSelected': item.type!=1&&(homeTicketIndex==index) }">
<div class="homeItemTop" :class="{'whiteColor':homeTicketIndex==index}">
<img src="./img/dui.png" v-if="homeTicketIndex==index" alt="">
<img src="./img/yuan.png" v-if="homeTicketIndex!=index" alt="">
<p v-if="item.type==1" :class="{'whiteColor':homeTicketIndex==index}">{{item.name}}</p>
<p style="font-size:.88rem" :class="{'whiteColor':homeTicketIndex==index}" v-if="item.type!=1">{{item.dAmount}}<span>元 × {{item.countUsed}}张</span></p>
</div>
<p v-if="item.type==1" :class="['homeItemtitle',{'whiteColor':homeTicketIndex==index}]">222</p>
<p v-if="item.type!=1" :class="['homeItemtitle',{'whiteColor':homeTicketIndex==index}]">222</p>
<p :class="['timeLimit',{'whiteColor':homeTicketIndex==index}]">2</p>
<div class="homeListBtn">{{item.price}}元购买</div>
</li>
</ul>
直接函数拿:
homeListClick(index,item.id){}