当前位置:网站首页>El date picker time range control
El date picker time range control
2022-07-19 01:38:00 【Still】
demand : Show year , The maximum year is one more year than the current year , The minimum year is ten years less than the current year .
It is required that the year cannot be written dead , No matter how many years now , Should display the corresponding year .
format=“yyyy” Display format
value-format=“yyyy” value Format
timeRange The time limit
Be careful el-date-picker Needed value The required format is string.
<el-date-picker>
:clearable="false"
v-model="year"
format="yyyy"
type="year"
value-format="yyyy"
:picker-option="timeRange"
placeholder=" Choose the year "
</el-date-picker>
data() {
return {
year: ''
timeRange: {
disableDate:time => {
const date = new Date(); // Get the current time
const year = date.getFullYear(); // Get current year
const minYear = (year-10).toString(); // Current year decrease 10 year
const maxYear = (year-+1).toString(); // Current year plus 1 year
const timeYear = time.getFullYear(); // Current year
const eYear = timeYear.toString();
return eYear < minYear || eYear > maxYear; // Less than the minimum year , Disabled if it is greater than the maximum year
}
}
}
},
mounted() {
this.year = (new Date().getFullYear()).toString())
}
边栏推荐
猜你喜欢
随机推荐
[SWPU 2019] network TTL encryption and some related knowledge
Vue project deployment, cleaning cache
Assemblage stylisé de cartes de commutation auto - encapsulées
Libtomcrypt密码库的使用
uni-app微信小程序——商城(4)——商家
2022年暑假ACM热身练习1(总结)
mock平台的使用说明
nmap和nikto扫描
es6语法--解构赋值
自己封装的风格化的开关卡片组件
uni-app微信小程序——商城(7)——商品详情
今天的码农女孩做了关于生命周期的笔记以及动态时钟的练习
05_回顾Object.defineProperty
Replace special characters in URL (%e2%80%8b)
JSX compilation
Nodejs cross domain CORS
(六)test命令
Vue项目部署,清理缓存
05_ Review object defineProperty
Uni app wechat official account (5) - add and modify addresses









