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

相关推荐
几度泥的菜花20 分钟前
使用jQuery实现动态下划线效果的导航栏
前端·javascript·jquery
思茂信息33 分钟前
CST直角反射器 --- 距离多普勒(RD图), 毫米波汽车雷达ADAS
前端·人工智能·5g·汽车·无人机·软件工程
星星不打輰39 分钟前
Vue入门常见指令
前端·javascript·vue.js
好_快1 小时前
Lodash源码阅读-isNative
前端·javascript·源码阅读
好_快1 小时前
Lodash源码阅读-reIsNative
前端·javascript·源码阅读
好_快1 小时前
Lodash源码阅读-baseIsNative
前端·javascript·源码阅读
好_快1 小时前
Lodash源码阅读-toSource
前端·javascript·源码阅读
Oneforlove_twoforjob2 小时前
volta node npm yarn下载安装
前端·npm·node.js
咖啡の猫2 小时前
npm与包
前端·npm·node.js
徐福记c2 小时前
npm install -g @vue/cli 方式已经无法创建VUE3项目
前端·vue.js·npm