Skip to content

Commit

Permalink
fix(picker): column index is always zero (#2188)
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs authored Jul 18, 2023
1 parent 3368cd4 commit a31d475
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/picker-item/picker-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class PickerItem extends SuperComponent {
duration: 0, // 滚动动画延迟
value: '',
curIndex: 0,
columnIndex: 0,
labelAlias: 'label',
valueAlias: 'value',
};
Expand All @@ -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) {
Expand All @@ -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,
});
});
},
Expand Down
1 change: 1 addition & 0 deletions src/picker/picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit a31d475

Please sign in to comment.