picker组件手机端设置value值混乱?
picker组件 mod=multiSelector时,开发工具没问题,手机端设置value的值无效。
三列联动选择器。当选择最后一列时,设置了前两列的index值。在开发工具中没问题,但是手机端无效,选择第二列也是无效。
bindMultiPickerColumnChange: function (e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
let multiIndex = this.data.multiIndex; //picker组件value属性的值
let multiArray = []; //picker组件range属性的值
let areaData = this.data.areaData; //自定义的地区数据
multiArray[0] = [empty,...areaData];
multiIndex[e.detail.column] = e.detail.value;
if(e.detail.column == 0){
let index1 = e.detail.value > 0 ? e.detail.value-1 : 0;
multiArray[1] = [empty,...areaData[index1]['children']]; //empty为自定义的对象,目的是当选择时显示全部
multiArray[2] = [empty['children'][0],...areaData[index1]['children'][0]['children']];
multiIndex[1] = 0;//第二列的index
multiIndex[2] = 0;//第三列的index
}else if(e.detail.column == 1){
let index = multiIndex[0];
let index1 = index == 0 ? 0 : index-1;
let eValue = e.detail.value == 0 ? 0 : e.detail.value-1;
multiArray[1] = [empty,...areaData[index1]['children']];
multiArray[2] = [empty['children'][0],...areaData[index1]['children'][eValue]['children']];
//直接选择第二列时,第一列自动选择对应的上级地区
let index2 = index == 0 ? 1 : index;
multiIndex[0] = index2;
multiIndex[2] = 0;
}else{
let index = multiIndex[0];
let index1 = multiIndex[1];
let index2 = index > 0 ? index-1 : 0;
let index3 = index1 > 0 ? index1-1 : 0;
multiArray[1] = [empty,...areaData[index2]['children']];
multiArray[2] = [empty['children'][0],...areaData[index2]['children'][index3]['children']];
//直接选择第三列时,第一、二列自动选择对应的上级地区
let index4 = index == 0 ? 1 : index;
let index5 = index1 == 0 ? 1 : index1;
multiIndex[0] = index4;
multiIndex[1] = index5;
}
this.setData({
multiArray:multiArray,
multiIndex:multiIndex,
});
},
1 回复
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)