You can use the picker-options
attribute to set the minimum and maximum allowed dates for an el-date-picker
. Here's an example:文章来源:https://www.toymoban.com/news/detail-701891.html
<template>
<el-date-picker
v-model="selectedDate"
:picker-options="pickerOptions"
type="date"
placeholder="Select date"
></el-date-picker>
</template>
<script>
export default {
data() {
return {
selectedDate: null,
pickerOptions: {
disabledDate(time) {
const minDate = new Date();
minDate.setHours(0, 0, 0, 0); // set minimum date to start of today
const maxDate = new Date();
maxDate.setDate(maxDate.getDate() + 7); // set maximum date to 7 days from today's date
return time.getTime() < minDate.getTime() || time.getTime() > maxDate.getTime();
}
}
};
}
};
</script>
In the example above, the pickerOptions
object is used to set a disabledDate
function which disables all dates before the start of today (minDate
) and after 7 days from today's date (maxDate
). You can adjust these values to fit your specific needs.文章来源地址https://www.toymoban.com/news/detail-701891.html
到了这里,关于<el-date-picker> 设置可选时间的上下限的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!