当前位置:网站首页>el-date-picker时间范围控制
el-date-picker时间范围控制
2022-07-17 00:06:00 【静止呀】
需求:显示年份,最大年份比当前年份多一年,最小年份比当前年份少十年。
要求年份不能写死,无论现在几几年,都应该显示对应的年份。
format=“yyyy” 显示格式
value-format=“yyyy” value格式
timeRange 时间限制
注意el-date-picker需要的value需要的格式是string。
<el-date-picker>
:clearable="false"
v-model="year"
format="yyyy"
type="year"
value-format="yyyy"
:picker-option="timeRange"
placeholder="选择年"
</el-date-picker>
data() {
return {
year: ''
timeRange: {
disableDate:time => {
const date = new Date(); // 获取当前时间
const year = date.getFullYear(); // 获取当前年份
const minYear = (year-10).toString(); // 当前年减10年
const maxYear = (year-+1).toString(); // 当前年加1年
const timeYear = time.getFullYear(); // 当前年份
const eYear = timeYear.toString();
return eYear < minYear || eYear > maxYear; // 小于最小年份,大于最大年份的禁用
}
}
}
},
mounted() {
this.year = (new Date().getFullYear()).toString())
}
边栏推荐
- Replace special characters in URL (%e2%80%8b)
- 分布式之数据库和缓存双写一致性方案解析(转载)
- 今天的码农女孩学习了关于nodejs和REPL 交互式解释器的知识
- Uni app wechat applet - Mall (3) - Mall Homepage
- Day16 sorting, current limiting
- 1. Internet foundation
- (6) Test command
- Quine injection of SQL injection
- sql语句学习和pymysql的使用
- Vue project deployment, cleaning cache
猜你喜欢

Uni app wechat applet - Mall (7) - Product Details

页面布局——三栏布局解决方式

Common mode attack and shared prime of RSA

【ElenmentUI el-date-picker日期选择器,结束时间不得早于开始时间,且只能选择距开始时间指定天数的日期】

uni-app微信小程序——商城(8)——订单详情
![Record buuctf [netding Cup 2018] unfinish1 problem solving ideas](/img/29/6cf1eb89f1cbe087438645668ce103.png)
Record buuctf [netding Cup 2018] unfinish1 problem solving ideas

How to modify the color of a line of text in the elemtnui table (elemtnui table modifies the color of a line of text)

uni-app微信公众号(1)——网页授权登录

1. Internet foundation

JS intercepts the first few digits of the string or the last few digits of the string
随机推荐
uni-app微信小程序——商城(7)——商品详情
Common mode attack and shared prime of RSA
Vue project deployment, cleaning cache
微信推送-模版消息参数配置
Stack injection [strong net cup 2019] random note
JS string to object JS object to string JS string to object
MoveIt2——4.机器人模型和机器人状态
es可选链
MoveIt2——5.场景规划
[GFCTF 2021]Baby_ Cve-2021-41773 on the web
智能指针(shared_ptr、unique_ptr、weak_ptr)
How to modify the color of a line of text in the elemtnui table (elemtnui table modifies the color of a line of text)
gtest与gmock的安装与使用
MoveIt2——2.MoveIt在RViz中的快速入门
Maker-HarmonyOS应用开发培训笔记01
Codeforces round #664C
今天的码农女孩学习了关于nodejs和REPL 交互式解释器的知识
uniapp调用地图,进行位置查询,标记定位
Oracle automatic storage management (ASM)
(10)文件包含