el-date-picker如何自定义日期选择范围
时间: 2023-10-11 08:10:04 浏览: 184
要自定义日期选择范围,可以使用el-date-picker组件的type属性设置为"datetimerange",然后通过设置picker-options属性来限制日期选择的范围。在picker-options中,可以使用disabledDate方法来定义日期的禁用规则。例如,如果只想禁止选择今天之后的日期,可以设置disabledDate方法如下:
picker-options: {
disabledDate(time) {
return time.getTime() > Date.now() - 8.64e7;
},
},
这样设置之后,el-date-picker组件将只允许选择今天之前的日期。你还可以根据需求进一步扩展disabledDate方法来自定义日期选择的范围。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [el-date-picker 自定义日期选中](https://blog.csdn.net/qq_41054877/article/details/123830276)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [时间日期插件 datePicker 可以自定义样式和效果](https://download.csdn.net/download/shenenhua/7842553)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文