在一些时候我们需要限定某些日期是否可选。
这里限定一下可选月份儿为 3 / 6 / 9 / 12 其它都为不可选状态
<template>
<div class="block">
<span class="demonstration">默认</span>
<el-date-picker
v-model="value1"
type="month"
value-format="yyyyMM"
:picker-options="pickerTime" // 重点 1
placeholder="选择日期">
</el-date-picker>
</div>
</template>
<script>
export default {
data() {
return {
pickerTime: { // 重点 2
disabledDate: function(time) {
var curDate = (new Date()).getMonth();
return ((
time.getMonth() == 0 ||
time.getMonth() == 1 ||
time.getMonth() == 3 ||
time.getMonth() == 4 ||
time.getMonth() == 6 ||
time.getMonth() == 7 ||
time.getMonth() == 9 ||
time.getMonth() == 10
))
}
},
value1: '',
value2: '',
};
}
};
</script>