当前位置:网站首页>Question 4 - datepicker date selector, disabling two date selectors (start and end dates)
Question 4 - datepicker date selector, disabling two date selectors (start and end dates)
2022-06-24 08:19:00 【Wine tripod】
Business scenario :
according to 2 Date ( Start date 、 End date ) Query data , however The end date must be greater than or equal to the start date .
Problem description
Select after start date , The end date range must be greater than the start date ; Select after end date , The start date must be less than the end date .
Solution :
Use disabledDate To set the disabled status .
Specific code
The first 1 Step , Add attribute ,
:picker-options="startDatePicker"
,:picker-options="endDatePicker"
<el-form-item label=" Start date " prop="startDate">
<el-date-picker v-model="form.startDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" size="small" clearable placeholder=" Choose a start date " :picker-options="startDatePicker" >
</el-date-picker>
to
<el-date-picker v-model="form.endDate" type="date" value-format="yyyy-MM-dd 23:59:59" size="small" clearable placeholder=" Select end date " :picker-options="endDatePicker" >
</el-date-picker>
</el-form-item>
The first 2 Step , In components data register ,
startDatePicker、endDatePicker
return {
form: {
startDate: null,
endDate: null,
},
startDatePicker: this.beginDate(),
endDatePicker: this.processDate(),
};
The first 3 Step , Define method logic ,
beginDate、processDate
.
beginDate() {
let self = this;
return {
disabledDate(time) {
if (self.form.endDate) {
// Disable if the date value is greater than the end date
return time.getTime() > new Date(self.form.endDate);
}
},
};
},
// The end date must be greater than or equal to the start date
processDate() {
let self = this;
return {
disabledDate(time) {
// Disable if the date value is less than the start date
return (
new Date(self.form.startDate).getTime() > time.getTime()
);
},
};
},
Realization effect
边栏推荐
猜你喜欢
首次曝光 唯一全域最高等级背后的阿里云云原生安全全景图
2021-03-11 COMP9021第八节课笔记
[008] filter the table data row by row, jump out of the for cycle and skip this cycle VBA
PAT 1157:校庆
LabVIEW查找n个元素数组中的质数
GraphMAE----论文快速阅读
一文带你了解Windows操作系统安全,保护自己的电脑不受侵害
Model effect optimization, try a variety of cross validation methods (system operation)
C语言_字符串与指针的爱恨情仇
一文理解同步FIFO
随机推荐
软件工程导论——第三章——需求分析
Simple refraction effect
Saccadenet: use corner features to fine tune the two stage prediction frame | CVPR 2020
Introduction to software engineering - Chapter 2 - feasibility study
SQL intra statement operation
Shader common functions
Utilisation de la fermeture / bloc de base SWIFT (source)
LINQ query (2)
VsCode主题推荐
到底哪一首才是唐诗第一?
Chapter 3 curve graph of canvas
根据网络上的视频的m3u8文件通过ffmpeg进行合成视频
[nilm] non intrusive load decomposition module nilmtk installation tutorial
LabVIEW查找n个元素数组中的质数
More than observation | Alibaba cloud observable suite officially released
The first exposure of Alibaba cloud's native security panorama behind the only highest level in the whole domain
Swift Extension ChainLayout(UI的链式布局)(源码)
Solution of electric education system for intelligent supervision station
Examples of corpus data processing cases (reading multiple text files, reading multiple files specified under a folder, decoding errors, reading multiple subfolder text, batch renaming of multiple fil
Tool functions – get all files in the project folder