el-date-picker时间范围只能选五分钟之内

el-date-picker时间范围只能选五分钟之内

一、主要代码

javascript 复制代码
<el-date-picker
    type="datetime"
    size="small"
    value-format="yyyy-MM-dd HH:mm:ss"
    v-model="searchData.submitTimeCode"
    :editable="false"
    placeholder="选择开始日期"
    @change="changeEnddate()"
></el-date-picker>

<el-date-picker
    v-model="searchData.submitTimeCodeMin"
    type="datetime"
    size="small"
    placeholder="选择结束日期"
    value-format="yyyy-MM-dd HH:mm:ss"
    :editable="false"
    :picker-options="{
        disabledDate: time => {
            return (
                time.getTime() >
                    new Date(this.searchData.submitTimeCode).getTime() ||
                time.getTime() <
                    new Date(this.searchData.submitTimeCode).getTime() -
                        20 * 3600 * 1000
            )
        },

        selectableRange: dafaulttime,
    }"
></el-date-picker>


formatDate(data) {
  let now = new Date(data)
  var hour = now.getHours() < 10 ? '0' + now.getHours() : now.getHours()
  var minute = now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes()
  var second = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds()
  return hour + ':' + minute + ':' + second
},
changeEnddate() {
  let dafaulttime = new Date(this.searchData.submitTimeCode).getTime() + 10 * 60 * 1000 //开始时间之后的五分钟时间戳
  this.dafaulttime =
      this.formatDate(new Date(this.searchData.submitTimeCode).getTime()) +
      '-' +
      this.formatDate(dafaulttime)
},

链接: https://blog.csdn.net/qq_33769914/article/details/108754228

相关推荐
袁煦丞16 分钟前
2025.8.18实验室【代码跑酷指南】Jupyter Notebook程序员的魔法本:cpolar内网穿透实验室第622个成功挑战
前端·程序员·远程工作
Joker Zxc20 分钟前
【前端基础】flex布局中使用`justify-content`后,最后一行的布局问题
前端·css
无奈何杨23 分钟前
风控系统事件分析中心,关联关系、排行、时间分布
前端·后端
Moment29 分钟前
nginx 如何配置防止慢速攻击 🤔🤔🤔
前端·后端·nginx
晓得迷路了34 分钟前
栗子前端技术周刊第 94 期 - React Native 0.81、jQuery 4.0.0 RC1、Bun v1.2.20...
前端·javascript·react.js
前端小巷子36 分钟前
Vue 自定义指令
前端·vue.js·面试
玲小珑42 分钟前
Next.js 教程系列(二十七)React Server Components (RSC) 与未来趋势
前端·next.js
Mike_jia42 分钟前
UptimeRobot API状态监控:零成本打造企业级业务健康看板
前端
江城开朗的豌豆43 分钟前
React状态更新踩坑记:我是这样优雅修改参数的
前端·javascript·react.js
CodeSheep1 小时前
Stack Overflow,轰然倒下了!
前端·后端·程序员