我在简单模式回购中发现了一个问题。以下是您的代码在静态最小/最大日期下的外观:
startDate: {
type: Date,
optional: true,
min: new Date(2016, 1, 1),
autoform: {
type: "bootstrap-datepicker"
}
},
endDate: {
type: Date,
optional: true,
max: new Date(2018, 1, 1),
autoform: {
type: "bootstrap-datepicker"
}
}
custom
如果您想让这些日期动态化,您可以使用验证器。这是相关文档的链接。您的开始日期将如下所示:
startDate: {
type: Date,
optional: true,
custom: function() {
var myMinDate = new Date(); //today
if(myMinDate > this.value) {
return 'minDate'; //Error string according to the docs.
} else {
return true;
}
},
autoform: {
type: "bootstrap-datepicker"
}
},
endDate: {
type: Date,
optional: true,
custom: function() {
var myMaxDate = new Date(2018, 11, 31); //Last day of 2018
if(myMaxDate < this.value) {
return 'maxDate'; //Error string according to the docs.
} else {
return true;
}
},
autoform: {
type: "bootstrap-datepicker"
}
}