:picker-options="pickerOptions" //标签内添加的
//下面是全局data中写的
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now() - 8.64e6;
}
},
日历中上月,今天,下月的点击事件绑定
this.$nextTick(() => {
// 点击上个月
let prevBtn = document.querySelector(
'.el-calendar__button-group .el-button-group>button:nth-child(1)');
prevBtn.addEventListener('click', () => {
//这里是使用.el-button-group>button:nth-child(1)这个伪类来判断给哪个按钮加事件
// console.log(111)
})
})
this.$nextTick(() => {
// 点击今天
let prevBtn = document.querySelector(
'.el-calendar__button-group .el-button-group>button:nth-child(2)');
prevBtn.addEventListener('click', () => {
// console.log(22)
})
})
this.$nextTick(() => {
// 点击下个月
let prevBtn = document.querySelector(
'.el-calendar__button-group .el-button-group>button:nth-child(3)');
prevBtn.addEventListener('click', () => {
// console.log(333)
})
})