当前位置:网站首页>问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用
问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用
2022-06-24 06:57:00 【酒鼎】
业务场景:
根据2个日期(开始日期、结束日期)查询数据,但是结束日期必须大于等于开始日期。
问题描述
选择开始日期之后,结束日期的范围必须大于开始日期;选择结束日期之后,开始日期必须小于结束日期。
解决方案:
使用disabledDate来设置禁用状态。
具体代码
第1步,添加属性,
:picker-options="startDatePicker",:picker-options="endDatePicker"
<el-form-item label="开始日期" prop="startDate">
<el-date-picker v-model="form.startDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" size="small" clearable placeholder="选择开始日期" :picker-options="startDatePicker" >
</el-date-picker>
至
<el-date-picker v-model="form.endDate" type="date" value-format="yyyy-MM-dd 23:59:59" size="small" clearable placeholder="选择结束日期" :picker-options="endDatePicker" >
</el-date-picker>
</el-form-item>
第2步,在组件data注册,
startDatePicker、endDatePicker
return {
form: {
startDate: null,
endDate: null,
},
startDatePicker: this.beginDate(),
endDatePicker: this.processDate(),
};
第3步,定义方法逻辑,
beginDate、processDate。
beginDate() {
let self = this;
return {
disabledDate(time) {
if (self.form.endDate) {
// 将日期值大于结束日期的禁用
return time.getTime() > new Date(self.form.endDate);
}
},
};
},
// 结束日期必须大于等于开始日期
processDate() {
let self = this;
return {
disabledDate(time) {
// 将日期值小于开始日期的禁用
return (
new Date(self.form.startDate).getTime() > time.getTime()
);
},
};
},
实现效果

边栏推荐
- 宝塔面板安装php7.2安装phalcon3.3.2
- All you know is the test pyramid?
- 研究生英语期末考试复习
- [teacher zhaoyuqiang] use the Oracle tracking file
- Practice of opengauss database on CentOS, configuration
- GraphMAE----论文快速阅读
- decltype用法介绍
- Swift Extension NetworkUtil(网络监听)(源码)
- Introduction to software engineering - Chapter 3 - Requirements Analysis
- 2021-03-09 COMP9021第七节课笔记
猜你喜欢

Part 1: building OpenGL environment

Installation and use of selenium IDE

Graphmae - - lecture rapide des documents

Coordinate transformation of graphic technology

Case examples of corpus data processing (cases related to sentence retrieval)

首次曝光 唯一全域最高等级背后的阿里云云原生安全全景图

Swift Extension NetworkUtil(網絡監聽)(源碼)

Swift extension chainlayout (UI chain layout) (source code)

1279_VMWare Player安装VMWare Tools时VSock安装失败解决

JDBC 在性能测试中的应用
随机推荐
From jsonpath and XPath to spl
3-list introduction
Graphmae ---- quick reading of papers
Oracle advanced SQL qualified query
June 27, 2021: given a positive array arr, it represents the weight of several people
Solution of electric education system for intelligent supervision station
Swift extension chainlayout (UI chain layout) (source code)
Swift Extension NetworkUtil(网络监听)(源码)
【点云数据集介绍】
SQL intra statement operation
Analysis of abnormal problems in domain name resolution in kubernetes
解决笔记本键盘禁用失败问题
Écouter le réseau d'extension SWIFT (source)
软件工程导论——第二章——可行性研究
宝塔面板安装php7.2安装phalcon3.3.2
The monthly salary of two years after graduation is 36K. It's not difficult to say
Backup and restore SQL Server Databases locally
Leetcode 207: course schedule (topological sorting determines whether the loop is formed)
You get in Anaconda
LINQ query (2)