feat(DatePicker): support columns-order (#6672) (#6768)

This commit is contained in:
Sylvaner
2020-07-14 11:55:14 +08:00
committed by GitHub
parent f782edc6a4
commit ea0708357f
6 changed files with 315 additions and 49 deletions
+37
View File
@@ -217,6 +217,42 @@ export default {
};
```
### 自定义列排序
```html
<van-datetime-picker
v-model="currentDate"
type="date"
title="自定义列排序"
:columns-order="['month', 'day', 'year']"
:formatter="formatter"
/>
```
```js
export default {
data() {
return {
currentDate: new Date(),
};
},
methods: {
formatter(type, val) {
if (type === 'year') {
return val + '年';
}
if (type === 'month') {
return val + '月';
}
if (type === 'day') {
return val + '日';
}
return val;
},
},
};
```
## API
### Props
@@ -231,6 +267,7 @@ export default {
| loading | 是否显示加载状态 | _boolean_ | `false` |
| filter | 选项过滤函数 | _(type, vals) => vals_ | - |
| formatter | 选项格式化函数 | _(type, val) => val_ | - |
| columns-order `v2.9.2` | 自定义列排序数组, 子项可选值为<br> `year``month``day``hour``minute` | _string[]_ | - |
| item-height `v2.8.6` | 选项高度,支持 `px``rem` 单位,默认 `px` | _number \| string_ | `44` |
| visible-item-count | 可见的选项个数 | _number \| string_ | `5` |
| swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` |