当前位置:网站首页>disabledDate 日期选择器 datePicker
disabledDate 日期选择器 datePicker
2022-08-05 05:24: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.30前不可选
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.11前不可选,2022.5.8后面不可选
return time.getTime() > new Date(2022, 5, 8) || time.getTime() < new Date(2021, 11, 11);
}
}
};
}
案例
**需求描述:**起止日期,取值范围在3个月内,并且不能选择超过当天的时间![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(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>
边栏推荐
- 错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
- 时间复杂度和空间复杂度
- [问题已处理]-虚拟机报错contains a file system with errors check forced
- Insight into the general trend of the Internet, after reading this article, you will have a thorough understanding of Chinese domain names
- Unity realizes first-person roaming (nanny-level tutorial)
- 微信小程序页面跳转传参
- Transport layer protocol (TCP 3-way handshake)
- Spark source code - task submission process - 6-sparkContext initialization
- 监控系统的内卷,有什么讲究?
- Getting Started Documentation 10 Resource Mapping
猜你喜欢

VLAN详解及实验
![[Day5] Soft and hard links File storage, deletion, directory management commands](/img/15/7ed58a180a72ace3463626bf446633.png)
[Day5] Soft and hard links File storage, deletion, directory management commands

Technology Sharing Miscellaneous Technologies
![[问题已处理]-jenkins流水线checkout超时](/img/3d/c14276d2b5ce18fc3d1288abb059c0.png)
[问题已处理]-jenkins流水线checkout超时
时间复杂度和空间复杂度

ALC实验

Getting Started Doc 08 Conditional Plugins

lvm logical volume and disk quota

Getting Started Documentation 12 webserve + Hot Updates
![[Day1] (Super detailed steps) Build a soft RAID disk array](/img/40/cda8e5522c2795e03c0d47e8a689f8.png)
[Day1] (Super detailed steps) Build a soft RAID disk array
随机推荐
从“双卡双待“到”双通“,vivo率先推动DSDA架构落地
通过反射获取Class对象的四种方式
Advantages of overseas servers
Spark source code-task submission process-6.1-sparkContext initialization-create spark driver side execution environment SparkEnv
VLAN details and experiments
Technology Sharing Miscellaneous Technologies
ACLs and NATs
Switch principle
Network wiring and digital-to-system conversion
spark operator - map vs mapPartitions operator
5分钟完成mysql离线安装
正则表达式小示例--获取重复最多的字符及其数量
flink cdc 目前支持Gauss数据库源吗
Hugo builds a personal blog
千亿IT运维市场,产品要凭实力说话
The idea of commonly used shortcut key
VLAN详解及实验
VLAN介绍与实验
传输层协议(TCP3次握手)
One-arm routing and 30% switch