apppws
apppws
  • 发布:2024-04-16 15:40
  • 更新:2024-07-11 10:08
  • 阅读:169

#插件讨论# 【 zxz-uni-datetime-picker 日期选择器(添加多选日期、多选年、多选月、范围月、单 - 1***@qq.com 】多选报错

分类:uni-app

我type==“dates” 时候 this.calendarList.push is not a function报错 VueComponent.choiceDate (zxz-calendar.js:950) 怎么解决啊

2024-04-16 15:40 负责人:无 分享
已邀请:
z***@qq.com

z***@qq.com

修改zxz-calendar.vue方法:

choiceDate(weeks) {
if (weeks.disable) return;
if (!weeks.fullDate) {
console.error('Invalid fullDate:', weeks.fullDate);
return;
}
if (this.type == 'dates') {
// 确保 calendarList 是数组
if (typeof this.calendarList === 'string') {
this.calendarList = this.calendarList.split(','); // 或者初始化为 []
} else if (!Array.isArray(this.calendarList)) {
this.calendarList = [];
}
this.calendarList = this.calendarList.filter(date => date);
if (this.calendarList.includes(weeks.fullDate)) {
let index = this.calendarList.findIndex((e) => e == weeks.fullDate);
this.calendarList.splice(index, 1);
} else {
this.calendarList.push(weeks.fullDate); // 这里应该不会报错
}
return;
}
// 其他逻辑
}

要回复问题请先登录注册