滚动选择器,做完联动后,无法滚动选择了
发布于 6 年前 作者 bli 12718 次浏览 来自 问答

以下是我的代码

.wxml

<picker mode=‘multiSelector’ range=’{{multiRangeO}}’ range-key=‘name’ bindchange=‘multiPickerAOChange’ bindcolumnchange=‘multiPickerAOColumnChange’>省市县联动</picker>

.js

data: {

multiRangeO: []

}

onLoad: function (options) {

this.setData({

multiRangeO: [[{ id: 0, name: ‘北京’ }, { id: 1, name: ‘上海’ }, { id: 2, name: ‘天津’ }, { id: 3, name: ‘重庆’ }], [{ id: 0, name: ‘北京’ }], [{ id: 0, name: ‘朝阳区’ }, { id: 1, name: ‘海淀区’ }, { id: 2, name: ‘东城区’ }, { id: 3, name: ‘西城区’ }]]

})

}

multiPickerAOColumnChange: function (e) {

console.log(e)

var multiRangeO = this.data.multiRangeO

switch (e.detail.column) {

case 0:

switch (e.detail.value) {

case 0:

multiRangeO.splice(1, 1, [{ id: 0, name: ‘北京’ }])

multiRangeO.splice(2, 1, [{ id: 0, name: ‘朝阳区’ }, { id: 1, name: ‘海淀区’ }, { id: 2, name: ‘东城区’ }, { id: 3, name: ‘西城区’ }])

this.setData({

multiRangeO: multiRangeO

})

console.log(this.data.multiRangeO)

break

case 1:

multiRangeO.splice(1, 1, [{ id: 0, name: ‘上海’ }])

multiRangeO.splice(2, 1, [{ id: 4, name: ‘徐汇区’ }, { id: 5, name: ‘长宁区’ }, { id: 6, name: ‘静安区’ }, { id: 7, name: ‘闸北区’ }])

this.setData({

multiRangeO: multiRangeO

})

console.log(this.data.multiRangeO)

break

case 2:

multiRangeO.splice(1, 1, [{ id: 0, name: ‘天津’ }])

multiRangeO.splice(2, 1, [{ id: 8, name: ‘东丽区’ }, { id: 9, name: ‘和平区’ }, { id: 10, name: ‘河北区’ }, { id: 11, name: ‘河东区’ }])

this.setData({

multiRangeO: multiRangeO

})

console.log(this.data.multiRangeO)

break

case 3:

multiRangeO.splice(1, 1, [{ id: 0, name: ‘重庆’ }])

multiRangeO.splice(2, 1, [{ id: 12, name: ‘万州区’ }, { id: 13, name: ‘涪陵区’ }, { id: 14, name: ‘梁平县’ }, { id: 15, name: ‘南川区’ }])

this.setData({

multiRangeO: multiRangeO

})

console.log(this.data.multiRangeO)

break

}

break

}

}

联动效果实现了,但是第二列和第三列无法滚动了,点击确定后e.detail.value=[1,null,null],如下图,求大神指教

1 回复

求大神们帮忙看看

回到顶部