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

相关推荐
weixin_5841214316 小时前
vue内i18n国际化移动端引入及使用
前端·javascript·vue.js
imkaifan16 小时前
bind函数--修改this指向,返回一个函数
开发语言·前端·javascript·bind函数
xkxnq16 小时前
第一阶段:Vue 基础入门(第 7 天)
前端·javascript·vue.js
光头闪亮亮16 小时前
企业协同办公系统(OA)-【图标选择器】模块开发详解
前端·javascript·vue.js
pas13616 小时前
22-mini-vue props
前端·javascript·vue.js
pas13616 小时前
23-mini-vue 实现 emit 功能
前端·javascript·vue.js
黛色正浓16 小时前
leetCode-热题100-子串合集(JavaScript)
javascript·算法·leetcode
程序员Agions16 小时前
React 自定义 Hooks 生存指南:7 个让你少加班的"偷懒"神器
前端·javascript
爱学习的小康16 小时前
js 文件读取 修改 创建
前端·javascript·vue.js
Sailing17 小时前
AI 流式对话该怎么做?SSE、fetch、axios 一次讲清楚
前端·javascript·面试