feat(Picker): default-index can be string

This commit is contained in:
陈嘉涵 2020-01-29 15:39:05 +08:00
parent ebe6e67453
commit cd3cc07254
3 changed files with 5 additions and 5 deletions

View File

@ -267,7 +267,7 @@ export default {
| 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` |
| default-index | Default value index of single column picker | *number \| string* | `0` |
| 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 animationunit `ms` | *number \| string* | `1000` |

View File

@ -281,7 +281,7 @@ export default {
| loading | 是否显示加载状态 | *boolean* | `false` |
| show-toolbar | 是否显示顶部栏 | *boolean* | `false` |
| allow-html `v2.1.8` | 是否允许选项内容中渲染 HTML | *boolean* | `true` |
| default-index | 单列选择时,默认选中项的索引 | *number* | `0` |
| default-index | 单列选择时,默认选中项的索引 | *number \| string* | `0` |
| item-height | 选项高度 | *number \| string* | `44` |
| visible-item-count | 可见的选项个数 | *number \| string* | `5` |
| swipe-duration `v2.2.10` | 快速滑动时惯性滚动的时长,单位`ms` | *number \| string* | `1000` |

View File

@ -14,7 +14,7 @@ export default createComponent({
props: {
...pickerProps,
defaultIndex: {
type: Number,
type: [Number, String],
default: 0,
},
columns: {
@ -81,7 +81,7 @@ export default createComponent({
let cursor = { children: this.columns };
while (cursor && cursor.children) {
const defaultIndex = cursor.defaultIndex || this.defaultIndex;
const defaultIndex = cursor.defaultIndex || +this.defaultIndex;
formatted.push({
values: cursor.children.map(item => item[this.valueKey]),
@ -270,7 +270,7 @@ export default createComponent({
allowHtml={this.allowHtml}
className={item.className}
itemHeight={this.itemHeight}
defaultIndex={item.defaultIndex || this.defaultIndex}
defaultIndex={item.defaultIndex || +this.defaultIndex}
swipeDuration={this.swipeDuration}
visibleItemCount={this.visibleItemCount}
initialOptions={item.values}