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
@@ -208,6 +208,42 @@ export default {
};
```
### Columns Order
```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 + ' Year';
}
if (type === 'month') {
return val + ' Month';
}
if (type === 'day') {
return val + ' Day';
}
return val;
},
},
};
```
## API
### Props
@@ -222,6 +258,7 @@ export default {
| loading | Whether to show loading prompt | _boolean_ | `false` |
| filter | Option filter | _(type, vals) => vals_ | - |
| formatter | Option text formatter | _(type, val) => val_ | - |
| columns-order `v2.9.2` | Array for ordering columns, where item can be set to<br> `year`, `month`, `day`, `hour` and `minute` | _string[]_ | - |
| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` |
| visible-item-count | Count of visible columns | _number \| string_ | `5` |
| swipe-duration `v2.2.13` | Duration of the momentum animationunit `ms` | _number \| string_ | `1000` |