当前位置:网站首页>DisabledDate date picker datePicker
DisabledDate date picker datePicker
2022-08-05 06:22:00 【MoXinXueWEB】
单选
<el-date-picker v-model="endDate" :picker-options="endDateOpt"></el-date-picker>
data() {
return {
startDate: null,
endDate: null,
endDateOpt: {
disabledData: (time) => {
// 2021.12.30Not optional before
return time.getTime() < new Date(2021, 11, 30);
}
}
}
}
区间daterange或datetimerange情况
<el-date-picker v-model="value" type="daterange"
:picker-options="pickerOptions">
</el-date-picker>
data() {
return {
value: '',
pickerOptions: {
disabledDate: (time) => {
// 注意是||不是&&
// 表示2021.12.11Not optional before,2022.5.8The latter is not optional
return time.getTime() > new Date(2022, 5, 8) || time.getTime() < new Date(2021, 11, 11);
}
}
};
}
案例
**需求描述:**起止日期,取值范围在3个月内,And can not select more than the time of the day![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8Wr7CHNb-1654686674837)(C:\Users\huawei\AppData\Roaming\Typora\typora-user-images\image-20220608184249187.png)]](/img/94/a14ee1e8ff4b2136afdbd816e980e1.png)
实现代码:
<template>
<div>
<span>起止日期:</span>
<el-date-picker v-model="startdate" type="date" placeholder="开始日期" :picker-options="pickerOption0" value-format="yyyyMMdd" format="yyyyMMdd">
</el-date-picker> -
<el-date-picker v-model="enddate" type="date" placeholder="结束日期" :picker-options="pickerOption1" value-format="yyyyMMdd" format="yyyyMMdd">
</el-date-picker>
</div>
</template>
<script>
export default {
data() {
return {
startdate: '',
enddate: ''
}
},
computed: {
pickerOption0() {
let obj = {}
obj.disabledDate = time => {
if (this.enddate != '' && this.enddate != null) {
let value = this.enddate.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
let d = new Date(value);
d.setMonth(d.getMonth() - 3);
return time.getTime() > new Date(value) || time.getTime() < d;
} else {
return time.getTime() > new Date();
}
};
return obj;
},
pickerOption1() {
let obj = {}
obj.disabledDate = time => {
if (this.startdate != '' && this.startdate != null) {
let value = this.startdate.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
let d = new Date(value);
d.setMonth(d.getMonth() + 3);
return time.getTime() > d || time.getTime() > new Date(value);
} else {
return time.getTime() > new Date();
}
};
return obj;
},
},
}
</script>
边栏推荐
猜你喜欢

解决这三大问题,运维效率将超90%的医院

VLAN介绍与实验

Mina断线重连

单臂路由实验和三层交换机实验

From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture

I/O performance and reliability

Mongodb query analyzer parsing

The problem come from line screening process

spark source code - task submission process - 1-sparkSubmit

OpenCV3.0 is compatible with VS2010 and VS2013
随机推荐
TCP/IP four-layer model
ROS2下使用ROS1 bag的方法
spark operator-textFile operator
config.js相关配置汇总
Unity realizes first-person roaming (nanny-level tutorial)
运维工程师,快来薅羊毛
Insight into the general trend of the Internet, after reading this article, you will have a thorough understanding of Chinese domain names
产品学习资料
Spark source code-task submission process-6.2-sparkContext initialization-TaskScheduler task scheduler
Transport layer protocol (TCP 3-way handshake)
时间复杂度和空间复杂度
Mina断线重连
七种让盒子水平垂直居中的方法
网络不通?服务丢包?看这篇就够了
The problem come from line screening process
增长:IT运维发展趋势报告
智能运维会取代人工运维吗?
js动态获取屏幕宽高度
Disk management and file systems
idea 常用快捷键