<view wx:for="{{homelist.properties}}" //外层循环
wx:for-item="v"
wx:for-index="i"
wx:key="id"
>
<view class="hoemH1">{{v.name}}</view>
<view class="homeH2">
<text
wx:for="{{v.childsCurGoods}}"
class="homeH3 {{item.id==curentIndex[i]?'active':''}}"
data-index="{{item.id}}" //传入id
data-id="{{i}}" //传入 上面是第几项
wx:key="id"
bindtap="homeColor"
>{{item.name}}</text>
</view>
</view>
data:{
curentIndex:[]
}
let arr=[];
for (let i = 0; i < res.data.data.properties.length;i++){
arr.push(res.data.data.properties[i].id)
}
this.setData({
curentIndex: arr
})
homeColor:function(e){
console.log(e.currentTarget.dataset)
let ss = "curentIndex[" + e.currentTarget.dataset.id+"]";
this.setData({
[ss]: e.currentTarget.dataset.index
})
}