wxml Link to heading
<view>
<block wx:for="{{test}}" wx:key="*this">
<button type='primary' size='mini' bindtap='chageval' data-id='{{item.id}}'>{{item.name}}</button>
<text>{{item.val}}</text>
</block>
</view>
js Link to heading
test: [
{
id: 1,
name: 'wangyu',
val: '123'
},
{
id: 2,
name: 'mayan',
val: '456'
}
]
chageval(e){
var x = e.currentTarget.dataset.id;
console.log(x);
var str = "test[" + (x-1) + "].val";
this.setData({
[str]: 'aaa'+x
});
}