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

相关推荐
独泪了无痕12 小时前
Lodash-JavaScript的实用工具库
前端·javascript
有趣的老凌12 小时前
用 Vibe Coding 搭了一个完整小程序「一定能成」
前端·javascript·后端
山河木马1 天前
矩阵专题3-怎么创建投影矩阵(uProjectionMatrix)
javascript·webgl·计算机图形学
泯泷1 天前
第 2 篇:设计第一套字节码:Opcode、Instruction 与 Constant Pool
前端·javascript·安全
泯泷1 天前
第 1 篇:从 1 + 2 开始:亲手写出第一台 JSVM
前端·javascript·安全
古夕1 天前
第三方 SSO 接入实践:redirect_uri 编码、回调一致性与跨项目联调
前端·vue.js
朦胧之1 天前
页面白屏卡住排查方法
前端·javascript
Ruihong1 天前
Vue withDefaults 转 React:VuReact 怎么处理?
vue.js·react.js·面试
犇驫聊AI1 天前
Chrome DevTools MCP + Claude Code 自定义skills生成接口代码生成器
前端·javascript
kyriewen1 天前
别再这样写 async/await 了:我在 Code Review 中见过最多的 8 个错误
前端·javascript·面试