el-date-picker 组件
文章目录
- [el-date-picker 组件](#el-date-picker 组件)
-
- [el-date-picker 只有某些日期可选](#el-date-picker 只有某些日期可选)
el-date-picker 只有某些日期可选
bash
<template>
<div>
<el-form
ref="form"
size="mini"
:model="form"
:rules="rules"
label-width="80px"
>
<el-row>
<el-col :span="8">
<el-form-item label="统计时间" prop="date">
<el-date-picker
type="date"
clearable
v-model="form.date"
value-format="yyyy-MM-dd"
placeholder="选择日期"
style="width: 100%;"
:picker-options="pickerOptions"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
export default {
data() {
return {
form: {
date: "",
},
allowedDates: ['2024-12-01', '2024-12-05', '2024-12-10'],
}
},
mounted() {
},
computed: {
// 日期可选项处理
pickerOptions(time) {
const _this = this
return {
disabledDate(time) {
const date = _this.$moment(time).format("YYYY-MM-DD");
return !_this.allowedDates.includes(date)
}
}
}
},
methods: {
}
}
</script>
<style lang="less" scoped>
.el-date-picker, .el-select {
width: 100%;
}
</style>