mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Picker): some prop can be string type
This commit is contained in:
parent
c6f424baa7
commit
ecdaf3f837
@ -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);
|
||||
},
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 | 单列选择器的默认选中项索引,<br>多列选择器请参考下方的 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 是单列或多列返回不同的参数
|
||||
当选择器有多列时,事件回调参数会返回数组
|
||||
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
|------|------|------|
|
||||
|
@ -283,7 +283,7 @@ export default createComponent({
|
||||
},
|
||||
|
||||
render(h) {
|
||||
const { itemHeight } = this;
|
||||
const itemHeight = +this.itemHeight;
|
||||
const wrapHeight = itemHeight * this.visibleItemCount;
|
||||
|
||||
const frameStyle = {
|
||||
|
@ -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,
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user