当前位置:网站首页>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个月内,并且不能选择超过当天的时间
实现代码:
<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>
边栏推荐
- 单臂路由与三成交换机
- One-arm routing and 30% switch
- Insight into the general trend of the Internet, after reading this article, you will have a thorough understanding of Chinese domain names
- VRRP原理及命令
- idea 常用快捷键
- Transport layer protocol (TCP 3-way handshake)
- [问题已处理]-虚拟机报错contains a file system with errors check forced
- flink cdc 目前支持Gauss数据库源吗
- ACL 和NAT
- spark operator-wholeTextFiles operator
猜你喜欢
Unity realizes first-person roaming (nanny-level tutorial)
运维的高光时刻,从智能化开始
云计算——osi七层与TCP\IP协议
Getting Started Documentation 12 webserve + Hot Updates
错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
Why can't I add a new hard disk to scan?How to solve?
The problem come from line screening process
spark source code-RPC communication mechanism
时间复杂度和空间复杂度
Getting Started Document 09 Standalone watch
随机推荐
Switch principle
spark source code - task submission process - 5-CoarseGrainedExecutorBackend
Mongodb查询分析器解析
带你深入了解Cookie
干货!教您使用工业树莓派结合CODESYS配置EtherCAT主站
CIPU, what impact does it have on the cloud computing industry?
云计算——osi七层与TCP\IP协议
markdown editor template
The problem come from line screening process
vim的三种模式
路由器和静态路由的配置
Getting Started Document 09 Standalone watch
ROS video tutorial
【Day8】Knowledge about disk and disk partition
Hugo搭建个人博客
请问下通过flink sql读取hologres 的两张表的 binlog,然后如何进行join?
LeetCode Interview Questions
VLAN details and experiments
VRRP概述及实验
千亿IT运维市场,产品要凭实力说话