HTML
<el-date-picker
v-model="value"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期"
:picker-options="pickerOptions">
</el-date-picker>
CSS
.color {
background-color: #ff0000;
}
JAVASCRIPT
data() {
return {
pickerOptions: this.date(),
value: '',
stopTime: [
"2020-08-01",
"2020-08-15",
"2020-08-29"
]
}
},
methods: {
date() {
let self = this;
return {
cellClassName(time) {
let day = time.getDate();
if (day < 10) {
day = "0" + day;
};
let month = time.getMonth() + 1
if (month < 10) {
month = "0" + month;
};
let year = time.getFullYear();
let res = year + "-" + month + "-" + day;
for (let i = 0; i < self.stopTime.length; i++) {
let _time = self.stopTime[i];
if (res == _time) {
return 'color';
}
}
}
}
},
}