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

相关推荐
像风一样自由20202 小时前
HTML与JavaScript:构建动态交互式Web页面的基石
前端·javascript·html
浪裡遊3 小时前
React Hooks全面解析:从基础到高级的实用指南
开发语言·前端·javascript·react.js·node.js·ecmascript·php
幽络源小助理3 小时前
SpringBoot基于Mysql的商业辅助决策系统设计与实现
java·vue.js·spring boot·后端·mysql·spring
Liudef064 小时前
2048小游戏实现
javascript·css·css3
鱼樱前端5 小时前
今天介绍下最新更新的Vite7
前端·vue.js
独立开阀者_FwtCoder6 小时前
【Augment】 Augment技巧之 Rewrite Prompt(重写提示) 有神奇的魔法
前端·javascript·github
我想说一句7 小时前
事件机制与委托:从冒泡捕获到高效编程的奇妙之旅
前端·javascript
汤姆Tom7 小时前
JavaScript reduce()函数详解
javascript
小飞悟7 小时前
你以为 React 的事件很简单?错了,它暗藏玄机!
前端·javascript·面试
中微子7 小时前
JavaScript 事件机制:捕获、冒泡与事件委托详解
前端·javascript