From 2c334efb4a70df3c9d84aef68cb67e5f9d860767 Mon Sep 17 00:00:00 2001 From: Weijian <415794089@qq.com> Date: Mon, 2 Jul 2018 10:17:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpicker=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E6=97=B6=E5=80=99=E8=B7=B3?= =?UTF-8?q?=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/picker/index.vue | 45 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/components/picker/index.vue b/src/components/picker/index.vue index fb5cdfb88..4ecbc099f 100755 --- a/src/components/picker/index.vue +++ b/src/components/picker/index.vue @@ -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]) + } } } },