[new feature] DatetimePicker: add filter prop

This commit is contained in:
陈嘉涵
2019-05-23 17:06:56 +08:00
parent 14ac581ac6
commit ab441cca9e
6 changed files with 167 additions and 18 deletions
+35 -4
View File
@@ -94,10 +94,10 @@ export default {
```html
<van-datetime-picker
v-model="currentDate"
v-model="currentTime"
type="time"
:min-hour="minHour"
:max-hour="maxHour"
:min-hour="10"
:max-hour="20"
/>
```
@@ -105,12 +105,42 @@ export default {
export default {
data() {
return {
currentDate: '12:00'
currentTime: '12:00'
};
}
}
```
### Option Filter
```html
<van-datetime-picker
v-model="currentTime"
type="time"
:filter="filter"
/>
```
```js
export default {
data() {
return {
currentTime: '12:00'
};
},
methods: {
filter(type, options) {
if (type === 'minute') {
return options.filter(option => option % 5 === 0)
}
return options;
}
}
}
```
## API
### Props
@@ -124,6 +154,7 @@ export default {
| max-hour | Max hour for `time` type | `Number` | `23` |
| min-minute | Max minute for `time` type | `Number` | `0` |
| max-minute | Max minute for `time` type | `Number` | `59` |
| filter | Option filter | `(type, values) => values` | - |
| formatter | Option text formatter | `(type, value) => value` | - |
| title | Toolbar title | `String` | `''` |
| loading | Whether to show loading prompt | `Boolean` | `false` |