<view class="types" wx:for="{{lists[num1].type}}" wx:key="index" bindtap="sureType" data-item="{{item}}">{{item}}</view>
data数据如下
data:{
lists:[
{
title:'纸张',
type:['A4','A6'],
type1:'A4'
},
{
title:'单双面',
type:['单面','双面'],
type1:'单面'
},
{
title:'颜色',
type:['黑白','彩色'],
type1:'黑白'
}
],
num:2
}
需求是当我触发点击事件时,将lists数组第num项里的type1值改为点击事件传来的item,如下
sureType(e){
console.log(e.currentTarget.dataset.item)
let num=this.data.num
this.setData({
['lists['+num+'].type1']:e.currentTarget.dataset.item
})
this.onClose()
},
这样就可以改掉了