本文实例为大家分享了微信小程序多列选择器的具体代码,供大家参考,具体内容如下
/**
- 页面的初始数据
*/
data: {
objectMultiArray: [
[
{
id: 0,name: '无脊柱动物'
},{
id: 1,name: '脊柱动物'
}
],[
{
id: 0,name: '扁性动物'
},name: '线形动物'
},{
id: 2,name: '环节动物'
},{
id: 3,name: '软体动物'
},name: '节肢动物'
}
]
],multiIndex2: [0,0],},bindMultiPickerChange2: function (e) {
console.log('picker发送选择改变,携带值为',e.detail.value)
this.setData({
multiIndex2: e.detail.value
})
},bindMultiPickerColumnChange2: function (e) {
console.log('修改的列为',e.detail.column,',值为',e.detail.value);
var data = {
objectMultiArray: this.data.objectMultiArray,multiIndex2: this.data.multiIndex2
};
data.multiIndex2[e.detail.column] = e.detail.value;
switch (e.detail.column) {
case 0:
switch (data.multiIndex2[0]) {
case 0:
data.objectMultiArray[1] = [
{ id: 0,name: '扁性动物' },{ id: 1,name: '线形动物' },{ id: 2,name: '环节动物' },{ id: 3,name: '软体动物' },name: '节肢动物' }
];
// data.multiArray[2] = ['猪肉绦虫','吸血虫'];
break;
case 1:
data.objectMultiArray[1] = [
{ id: 0,name: '鱼' },name: '线形两栖动物' },name: '爬行动物' }
];
break;
}
data.multiIndex2[1] = 0;
// data.multiIndex[2] = 0;
break;
}
this.setData(data);
}
})
请记得点赞额!!!