Skip to content

Commit

Permalink
picker组件为多列选择器时range的长度变化不能正确工作的bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
mya12321 authored and ZakaryCode committed Aug 17, 2020
1 parent ac5e462 commit 4c0c20b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/taro-components/src/components/picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,25 @@ export default class Picker extends Nerv.Component {
range = []
this.props.range = []
}
if (range.length === this.index.length) this.index = []
range.forEach((r, i) => {
const v = value && value.length ? value[i] : undefined
this.index.push(this.verifyValue(v, r) ? Math.floor(value[i]) : 0)
})
if (range === this.props.range && this.props.value !== value) {
this.index = []
range.forEach((r, i) => {
const v = value && value.length ? value[i] : undefined
this.index.push(this.verifyValue(v, r) ? Math.floor(value[i]) : 0)
})
this.setState({
height: this.index.map(i => TOP - i * LINE_HEIGHT)
})
} else if (range.length !== this.index.length) {
range.forEach((r, i) => {
if (i >= this.index.length) {
this.index.push(0)
}
})
this.setState({
height: this.index.map(i => TOP - i * LINE_HEIGHT)
})
}
} else if (mode === 'time') {
// check value...
if (!this.verifyTime(value)) {
Expand Down

0 comments on commit 4c0c20b

Please sign in to comment.