在 el-date-picker 组件中加::picker-options="pickerOptions"
<el-form-item label="票据生成日期:">
<el-date-picker
v-model="date1"
type="daterange"
range-separator="至"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
/>
</el-form-item>
data() {
return {
date1: [],
pickerOptions: {
disabledDate: (time) => {
return time.getTime() > Date.now()
}
},
toolParams: {
issueTimeBegin: '',
issueTimeEnd: '',
}
},
watch: {
date1(val) {
this.toolParams.issueTimeBegin = val ? val[0] : ''
this.toolParams.issueTimeEnd = val ? val[1] : ''
}
}
效果: