vant组件现状
公司需求
为了解决此问题我们可以滚动加载日历,让日历结构保持在3年内
// 获取当前年
const currentYear = moment().toObject().years
设置一个 初始化的min-data 和max-date
const minDate= new Date(currentYear - 1, 0 , 1)
const maxDate = new Date(currentYear + 1, 11 , 31)
// 当month-show 执行时
monthShow (date) {
const {date, time} = date
const minCurrentYear = moment(minDate).toObject().years
const maxCurrentYear = moment(maxDate).toObject().years
const current. = moment(date).toObject().years
if (currentYear === minCurrentYear) {
this.minDate = new Date(minCurrentYear - 1, 0, 1)
dom.scrollTop = 6636 // 解决上滑动跨年 否则向上滑动的时候会有出现跨年
}
if (currentYear === maxCurrentYear) {
this.maxDate = new Date(maxCurrentYear + 1,11,31)
}
}
这样就解决卡顿的问题了~