![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8fec5a864717ac1518d3cd2e932560d8.png)
<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
}
}