<el-date-picker
v-model="dateTime"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
@change="dateTimeChange"
:picker-options="pickerOptions"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
pickerOptions: {
onPick: ({ maxDate, minDate }) => {
this.selectData = minDate.getTime()
if (maxDate) {
this.selectData = ''
}
},
disabledDate: (time) => {
if (!this.isNull(this.selectData)) {
var date = new Date(this.selectData)
return date.getMonth() > new Date(time).getMonth() || date.getMonth() < new Date(time).getMonth()
} else {
return false
}
}
}
methods: {
isNull(value) {
if (value) {
return false
}
return true
}
}