Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picker组件为多列选择器时range的长度变化不能正确工作的bug修复 #7320

Merged
merged 2 commits into from
Aug 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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