在 element-ui 日期选择器中禁用每周一
Disable every Monday in element-ui datepicker
如果我想禁用每个星期一或每个星期一和星期二,那么我该如何在元素的日期选择器中执行此操作-ui?
我找不到关于禁用星期几的文档。
data() {return { calendarOptions: { disabledDate: function(time) { return time.getTime() < Date.now();},},}}
var Main = {
data() {
return {
pickerOptions: {
disabledDate(time) {
return new Date(time).getDay() === 1;
}
},
value1: ''
};
}
};
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
@import url("//unpkg.com/element-ui@2.12.0/lib/theme-chalk/index.css");
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
<script src="//unpkg.com/element-ui@2.12.0/lib/index.js"></script>
<div id="app">
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker
v-model="value1"
type="date"
placeholder="Pick a day"
:picker-options="pickerOptions">
</el-date-picker>
</div>
</template>
</div>
disabledDate
选项可以设置为禁用。只需要判断当前日期是否为星期一,然后returntrue 禁用即可。
如果我想禁用每个星期一或每个星期一和星期二,那么我该如何在元素的日期选择器中执行此操作-ui?
我找不到关于禁用星期几的文档。
data() {return { calendarOptions: { disabledDate: function(time) { return time.getTime() < Date.now();},},}}
var Main = {
data() {
return {
pickerOptions: {
disabledDate(time) {
return new Date(time).getDay() === 1;
}
},
value1: ''
};
}
};
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
@import url("//unpkg.com/element-ui@2.12.0/lib/theme-chalk/index.css");
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
<script src="//unpkg.com/element-ui@2.12.0/lib/index.js"></script>
<div id="app">
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker
v-model="value1"
type="date"
placeholder="Pick a day"
:picker-options="pickerOptions">
</el-date-picker>
</div>
</template>
</div>
disabledDate
选项可以设置为禁用。只需要判断当前日期是否为星期一,然后returntrue 禁用即可。