效果图
代码
<el-date-picker v-model="rangeDate" :picker-options="pickerOptions" type="datetimerange" start-placeholder="开始日期" range-separator="至" end-placeholder="结束日期" />
/**
* 计算属性
*/
/** get 时间 */
get rangeDate() {
return [this.form.startTime, this.form.endTime]
}
/** set 时间 */
set rangeDate(v) {
if (!v) {
this.form.startTime = ''
this.form.endTime = ''
return
}
this.form.startTime = getDate(v[0], 'Y-M-D h:m:s')
this.form.endTime = getDate(v[1], 'Y-M-D h:m:s')
}
/** 时间选择器 */
private pickerOptions: any = {
disabledDate(time:any) {
return time.getTime() < new Date(new Date().toLocaleDateString()).getTime()
}
}