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

相关推荐
一 乐19 小时前
婚纱摄影网站|基于ssm + vue婚纱摄影网站系统(源码+数据库+文档)
前端·javascript·数据库·vue.js·spring boot·后端
C_心欲无痕19 小时前
ts - tsconfig.json配置讲解
linux·前端·ubuntu·typescript·json
清沫19 小时前
Claude Skills:Agent 能力扩展的新范式
前端·ai编程
yinuo20 小时前
前端跨页面通信终极指南:方案拆解、对比分析
前端
北辰alk20 小时前
Vue 模板引擎深度解析:基于 HTML 的声明式渲染
vue.js
北辰alk20 小时前
Vue 自定义指令完全指南:定义与应用场景详解
vue.js
yinuo20 小时前
前端跨页面通讯终极指南⑨:IndexedDB 用法全解析
前端
北辰alk20 小时前
Vue 动态路由完全指南:定义与参数获取详解
vue.js
北辰alk21 小时前
Vue Router 完全指南:作用与组件详解
vue.js
北辰alk21 小时前
Vue 中使用 this 的完整指南与注意事项
vue.js