<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.

相关推荐
奔跑的web.3 小时前
TypeScript 装饰器入门核心用法
前端·javascript·vue.js·typescript
阿蒙Amon3 小时前
TypeScript学习-第1章:入门
javascript·学习·typescript
winfredzhang3 小时前
实战复盘:如何用 HTML+JS+AI 打造一款“影迹”智能影视管理系统
javascript·html·json·加载·搜索·保存·电影接口
pas1363 小时前
37-mini-vue 解析插值
前端·javascript·vue.js
十里-4 小时前
vue.js 2前端开发的项目通过electron打包成exe
前端·vue.js·electron
雨季6665 小时前
构建 OpenHarmony 简易文字行数统计器:用字符串分割实现纯文本结构感知
开发语言·前端·javascript·flutter·ui·dart
雨季6665 小时前
Flutter 三端应用实战:OpenHarmony 简易倒序文本查看器开发指南
开发语言·javascript·flutter·ui
小北方城市网5 小时前
Redis 分布式锁高可用实现:从原理到生产级落地
java·前端·javascript·spring boot·redis·分布式·wpf
console.log('npc')5 小时前
vue2 使用高德接口查询天气
前端·vue.js
2401_892000525 小时前
Flutter for OpenHarmony 猫咪管家App实战 - 添加支出实现
前端·javascript·flutter