<el-date-picker> 设置可选时间的上下限

You can use the picker-options attribute to set the minimum and maximum allowed dates for an el-date-picker. Here's an example:

html 复制代码
<template>
  <el-date-picker
    v-model="selectedDate"
    :picker-options="pickerOptions"
    type="date"
    placeholder="Select date"
  ></el-date-picker>
</template>

<script>
export default {
  data() {
    return {
        selectedDate: null,
        pickerOptions: {
          disabledDate(time) {
            const minDate = new Date();
            minDate.setHours(0, 0, 0, 0); // set minimum date to start of today
            const maxDate = new Date();
            maxDate.setDate(maxDate.getDate() + 7); // set maximum date to 7 days from today's date
            return time.getTime() < minDate.getTime() || time.getTime() > maxDate.getTime();
          }
        }
    };
  }
};
</script>

In the example above, the pickerOptions object is used to set a disabledDate function which disables all dates before the start of today (minDate) and after 7 days from today's date (maxDate). You can adjust these values to fit your specific needs.

相关推荐
mCell8 小时前
GSAP ScrollTrigger 详解
前端·javascript·动效
gnip8 小时前
Node.js 子进程:child_process
前端·javascript
codingandsleeping14 小时前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
白水清风15 小时前
微前端学习记录(qiankun、wujie、micro-app)
前端·javascript·前端工程化
用户221520442780015 小时前
new、原型和原型链浅析
前端·javascript
阿星做前端15 小时前
coze源码解读: space develop 页面
前端·javascript
叫我小窝吧15 小时前
Promise 的使用
前端·javascript
用户516816614584116 小时前
Vue Router 路由懒加载引发的生产页面白屏问题
vue.js·vue-router
前端康师傅16 小时前
JavaScript 作用域
前端·javascript
前端缘梦16 小时前
Vue Keep-Alive 组件详解:优化性能与保留组件状态的终极指南
前端·vue.js·面试