mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
[new feature] DatetimePicker: add filter prop
This commit is contained in:
@@ -16,6 +16,7 @@ export default sfc({
|
||||
props: {
|
||||
...pickerProps,
|
||||
value: null,
|
||||
filter: Function,
|
||||
minHour: Number,
|
||||
minMinute: Number,
|
||||
type: {
|
||||
@@ -147,12 +148,16 @@ export default sfc({
|
||||
|
||||
columns() {
|
||||
const results = this.ranges.map(({ type, range: rangeArr }) => {
|
||||
const values = times(rangeArr[1] - rangeArr[0] + 1, index => {
|
||||
let values = times(rangeArr[1] - rangeArr[0] + 1, index => {
|
||||
let value = rangeArr[0] + index;
|
||||
value = value < 10 ? `0${value}` : `${value}`;
|
||||
return this.formatter(type, value);
|
||||
});
|
||||
|
||||
if (this.filter) {
|
||||
values = this.filter(type, values);
|
||||
}
|
||||
|
||||
return {
|
||||
values
|
||||
};
|
||||
@@ -170,6 +175,7 @@ export default sfc({
|
||||
correctValue(value) {
|
||||
// validate value
|
||||
const isDateType = this.type !== 'time';
|
||||
|
||||
if (isDateType && !isValidDate(value)) {
|
||||
value = this.minDate;
|
||||
} else if (!value) {
|
||||
|
Reference in New Issue
Block a user