一、主要代码
<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文章来源地址https://www.toymoban.com/news/detail-608339.html
文章来源:https://www.toymoban.com/news/detail-608339.html
到了这里,关于el-date-picker时间范围只能选五分钟之内的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!