diff --git a/src/picker/PickerColumn.js b/src/picker/PickerColumn.js index b2de06b74..df436e9ed 100644 --- a/src/picker/PickerColumn.js +++ b/src/picker/PickerColumn.js @@ -33,10 +33,10 @@ export default createComponent({ valueKey: String, allowHtml: Boolean, className: String, - itemHeight: Number, + itemHeight: [Number, String], defaultIndex: Number, - swipeDuration: Number, - visibleItemCount: Number, + swipeDuration: [Number, String], + visibleItemCount: [Number, String], initialOptions: { type: Array, default: () => [], @@ -228,7 +228,7 @@ export default createComponent({ const index = this.getIndexByOffset(distance); - this.duration = this.swipeDuration; + this.duration = +this.swipeDuration; this.setIndex(index, true); }, diff --git a/src/picker/README.md b/src/picker/README.md index 1a7a89b2c..20d56cd13 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -259,18 +259,18 @@ export default { | Attribute | Description | Type | Default | |------|------|------|------| | columns | Columns data | *Column[]* | `[]` | -| show-toolbar | Whether to show toolbar | *boolean* | `false` | -| toolbar-position | Toolbar position, cat be set to `bottom` | *string* | `top` | -| title | Toolbar title | *string* | `''` | -| loading | Whether to show loading prompt | *boolean* | `false` | -| value-key | Key of option text | *string* | `text` | -| item-height | Option height | *number* | `44` | +| title | Toolbar title | *string* | - | | confirm-button-text | Text of confirm button | *string* | `Confirm` | | cancel-button-text | Text of cancel button | *string* | `Cancel` | -| visible-item-count | Count of visible columns | *number* | `5` | +| value-key | Key of option text | *string* | `text` | +| toolbar-position | Toolbar position, cat be set to `bottom` | *string* | `top` | +| loading | Whether to show loading prompt | *boolean* | `false` | +| show-toolbar | Whether to show toolbar | *boolean* | `false` | | allow-html `v2.1.8` | Whether to allow HTML in option text | *boolean* | `true` | | default-index | Default value index of single column picker | *number* | `0` | -| swipe-duration `v2.2.10` | Duration of the momentum animation,unit `ms` | *number* | `1000` | +| item-height | Option height | *number \| string* | `44` | +| visible-item-count | Count of visible columns | *number \| string* | `5` | +| swipe-duration `v2.2.10` | Duration of the momentum animation,unit `ms` | *number \| string* | `1000` | ### Events diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index 02d391863..4c7bb4d08 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -273,22 +273,22 @@ export default { | 参数 | 说明 | 类型 | 默认值 | |------|------|------|------| | columns | 对象数组,配置每一列显示的数据 | *Column[]* | `[]` | -| show-toolbar | 是否显示顶部栏 | *boolean* | `false` | -| toolbar-position | 顶部栏位置,可选值为`bottom` | *string* | `top` | -| title | 顶部栏标题 | *string* | `''` | -| loading | 是否显示加载状态 | *boolean* | `false` | -| value-key | 选项对象中,文字对应的 key | *string* | `text` | -| item-height | 选项高度 | *number* | `44` | +| title | 顶部栏标题 | *string* | - | | confirm-button-text | 确认按钮文字 | *string* | `确认` | | cancel-button-text | 取消按钮文字 | *string* | `取消` | -| visible-item-count | 可见的选项个数 | *number* | `5` | +| value-key | 选项对象中,选项文字对应的键名 | *string* | `text` | +| toolbar-position | 顶部栏位置,可选值为`bottom` | *string* | `top` | +| loading | 是否显示加载状态 | *boolean* | `false` | +| show-toolbar | 是否显示顶部栏 | *boolean* | `false` | | allow-html `v2.1.8` | 是否允许选项内容中渲染 HTML | *boolean* | `true` | -| default-index | 单列选择器的默认选中项索引,
多列选择器请参考下方的 Columns 配置 | *number* | `0` | -| swipe-duration `v2.2.10` | 快速滑动时惯性滚动的时长,单位`ms` | *number* | `1000` | +| default-index | 单列选择时,默认选中项的索引 | *number* | `0` | +| item-height | 选项高度 | *number \| string* | `44` | +| visible-item-count | 可见的选项个数 | *number \| string* | `5` | +| swipe-duration `v2.2.10` | 快速滑动时惯性滚动的时长,单位`ms` | *number \| string* | `1000` | ### Events -Picker 组件的事件会根据 columns 是单列或多列返回不同的参数 +当选择器有多列时,事件回调参数会返回数组 | 事件名 | 说明 | 回调参数 | |------|------|------| diff --git a/src/picker/index.js b/src/picker/index.js index 21fda3c65..f0217a74f 100644 --- a/src/picker/index.js +++ b/src/picker/index.js @@ -283,7 +283,7 @@ export default createComponent({ }, render(h) { - const { itemHeight } = this; + const itemHeight = +this.itemHeight; const wrapHeight = itemHeight * this.visibleItemCount; const frameStyle = { diff --git a/src/picker/shared.ts b/src/picker/shared.ts index 085eee17a..7e8e619e5 100644 --- a/src/picker/shared.ts +++ b/src/picker/shared.ts @@ -3,7 +3,7 @@ export type SharedPickerProps = { loading?: boolean; itemHeight: number; showToolbar?: boolean; - visibleItemCount: number; + visibleItemCount: number | string; cancelButtonText?: string; confirmButtonText?: string; }; @@ -19,15 +19,15 @@ export const pickerProps = { default: true, }, visibleItemCount: { - type: Number, + type: [Number, String], default: 5, }, itemHeight: { - type: Number, + type: [Number, String], default: 44, }, swipeDuration: { - type: Number, + type: [Number, String], default: 1000, }, };