element中日期选择器设置选择范围
有效期只能选择成立时间之后的日期
<el-form-item label="成立时间" prop="establishmentDate">
<el-date-picker
v-model="form.establishmentDate"
type="date"
placeholder="请选择有效期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<el-form-item label="有效期" prop="validityDate">
<el-date-picker
v-model="form.validityDate"
type="date"
placeholder="请选择有效期"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
></el-date-picker>
</el-form-item>
js
export default {
data() {
return {
pickerOptions: {
disabledDate: (time) => {
if (this.form.establishmentDate) {
return (
time.getTime() < new Date(this.form.establishmentDate).getTime()
);
}
},
},
};
},
};