提交 42fa7854 编写于 作者: F Fyerl

修复 picker 通过 setData 改变数据列数发生变化时的问题

1. 列数增加: 增加的列对应的 scroll 未实例化无法滚动
2. 列数减少: pickerSelectedVal 保留了变化前选中的值
上级 bbdc727e
......@@ -123,6 +123,8 @@
let changed = false
let pickerSelectedText = []
this.pickerSelectedVal = []
for (let i = 0; i < this.pickerData.length; i++) {
let index = this.wheels[i].getSelectedIndex()
this.pickerSelectedIndex[i] = index
......@@ -187,10 +189,12 @@
this.pickerData = data.slice()
if (this.isVisible) {
this.$nextTick(() => {
this.wheels.forEach((wheel, i) => {
wheel.refresh()
wheel.wheelTo(this.pickerSelectedIndex[i])
const wheelWrapper = this.$refs.wheelWrapper
this.pickerData.forEach((item, i) => {
this._createWheel(wheelWrapper, i)
this.wheels[i].wheelTo(this.pickerSelectedIndex[i])
})
this.wheels.splice(this.pickerData.length, this.wheels.length - this.pickerData.length)
})
} else {
this.dirty = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册