<picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
<view class="picker">
当前选择:{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}},{{multiArray[2][multiIndex[2]]}}
</view>
</picker>
data: {
multiArray: [['1', '2'], ['1-1', '1-2']],
multiIndex: [0,0],
},
bindMultiPickerChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
multiIndex: e.detail.value
})
},
bindMultiPickerColumnChange: function (e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
var data = {
multiArray: this.data.multiArray,
multiIndex: this.data.multiIndex
};
data.multiIndex[e.detail.column] = e.detail.value;
if (e.detail.column===0) {
if (e.detail.value===0) {
data.multiArray[1] = ['1-1', '1-2'];
data.multiIndex[1] = 0;
}else{
data.multiArray[1] = ['2-1', '2-2'];
data.multiIndex[1] = 0;
}
}
console.log(data.multiIndex);
this.setData(data);
},
image.png
网友评论