实现了时间日期组件限制选择,生产日期不能大于结束日期。
<template>
<div class="hello">
{{starttime}}
<el-date-picker v-model="starttime" :picker-options="startTime" type="date" value-format="yyyy-MM-dd"></el-date-picker>
{{endtime}}
<el-date-picker v-model="endtime" :picker-options="endTime" type="date" value-format="yyyy-MM-dd"></el-date-picker>
</div>
</template>
<script>
export default {
data () {
return {
starttime: '',
endtime: '',
startTime: {
disabledDate: time => {
if (this.endtime) {
return (
time.getTime() > new Date(this.endtime).getTime()
)
} else {
return time.getTime() > Date.now()
}
}
},
endTime: {
disabledDate: time => {
if (this.starttime) {
return (
time.getTime() < new Date(this.starttime).getTime()
)
} else {
return time.getTime() > Date.now()
}
}
}
}
}
}
</script>