From a31d475c8cd462c797d823357e32a1b223187af6 Mon Sep 17 00:00:00 2001 From: betavs <34408516+betavs@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:21:23 +0800 Subject: [PATCH] fix(picker): column index is always zero (#2188) --- src/picker-item/picker-item.ts | 5 +++-- src/picker/picker.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/picker-item/picker-item.ts b/src/picker-item/picker-item.ts index 8be851149..b95f5c39c 100644 --- a/src/picker-item/picker-item.ts +++ b/src/picker-item/picker-item.ts @@ -51,6 +51,7 @@ export default class PickerItem extends SuperComponent { duration: 0, // 滚动动画延迟 value: '', curIndex: 0, + columnIndex: 0, labelAlias: 'label', valueAlias: 'value', }; @@ -76,7 +77,7 @@ export default class PickerItem extends SuperComponent { }, onTouchEnd() { - const { offset, labelAlias, valueAlias } = this.data; + const { offset, labelAlias, valueAlias, columnIndex } = this.data; const { options } = this.properties; if (offset === this.StartOffset) { @@ -99,7 +100,7 @@ export default class PickerItem extends SuperComponent { this._selectedLabel = options[index]?.[labelAlias]; this.$parent?.triggerColumnChange({ index, - column: this.columnIndex || 0, + column: columnIndex, }); }); }, diff --git a/src/picker/picker.ts b/src/picker/picker.ts index fe961cedd..483fc761c 100644 --- a/src/picker/picker.ts +++ b/src/picker/picker.ts @@ -52,6 +52,7 @@ export default class Picker extends SuperComponent { this.$children.forEach((child, index) => { child.setData({ value: value?.[index] ?? defaultValue?.[index] ?? '', + columnIndex: index, }); child.update(); });