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组件更新数据时候跳动的问题 #2896

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
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
45 changes: 28 additions & 17 deletions src/components/picker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,36 @@ export default {
return
}

_this.scroller[i] && _this.scroller[i].destroy()
_this.scroller[i] = new Scroller(_this.getId(i), {
data: data[i],
defaultValue: value[i] || data[i][0].value,
itemClass: _this.itemClass,
onSelect (value) {
_this.$set(_this.currentValue, i, value)
if (!this.columns || (this.columns && _this.getValue().length === _this.store.count)) {
_this.$nextTick(() => {
_this.$emit('on-change', _this.getValue())
})
}
if (_this.columns !== 0) {
_this.renderChain(i + 1)
}
if (_this.scroller[i]) {
let selectValue = _this.scroller[i].getValue()
if (_this.currentData[i].filter(item => item.value === selectValue).length === 0) {
_this.scroller[i] = _this.scroller[i].destroy()
}
})
}

if (typeof _this.scroller[i] === 'undefined') {
_this.scroller[i] = new Scroller(_this.getId(i), {
data: data[i],
defaultValue: value[i] || data[i][0].value,
itemClass: _this.itemClass,
onSelect (value) {
_this.$set(_this.currentValue, i, value)
if (!this.columns || (this.columns && _this.getValue().length === _this.store.count)) {
_this.$nextTick(() => {
_this.$emit('on-change', _this.getValue())
})
}
if (_this.columns !== 0) {
_this.renderChain(i + 1)
}
}
})
}

if (_this.currentValue) {
_this.scroller[i].select(value[i])
if (_this.scroller[i].getValue() !== value[i]) {
_this.scroller[i].select(value[i])
}
}
}
},
Expand Down