You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

开源Vue应用甘特图每年9月跳月问题无法复现求助

问题描述

我正在开发一款开源Vue应用,内置甘特图用于以时间线形式展示任务,支持用户自定义日期范围,默认展示当前月与下一个月。

每年9月该甘特图就会出现异常,不会完整展示所有月份,会跳过下一个月:
异常展示效果

预期的正确展示效果如下:
正确展示效果

该问题有对应的持续追踪issue。

问题难点

我无法复现该问题,即便使用Browserstack模拟用户完全相同的浏览器/操作系统组合,目前我测试过的所有设备和浏览器上功能均正常。由于无法复现,我难以对问题进行调试,更无法修复。

目前看来该问题仅影响少量用户。

相关代码

构建年/月/日数据结构的代码如下:

// Layout: years => [months => [days]]
let years = {}
for (
    let d = this.startDate;
    d <= this.endDate;
    d.setDate(d.getDate() + 1)
) {
    let date = new Date(d)
    if (years[date.getFullYear() + ''] === undefined) {
        years[date.getFullYear() + ''] = {}
    }
    if (
        years[date.getFullYear() + ''][date.getMonth() + ''] ===
        undefined
    ) {
        years[date.getFullYear() + ''][date.getMonth() + ''] = []
    }
    years[date.getFullYear() + ''][date.getMonth() + ''].push(date)
    this.fullWidth += this.dayWidth
}
this.$set(this, 'days', years) // 我知道这个变量名取得不太合理

前端模板渲染代码如下:

<template v-for="(y, yk) in days">
    <div :key="yk + 'year'" class="months">
        <div
            :key="mk + 'month'"
            class="month"
            v-for="(m, mk) in days[yk]"
        >
            {{
                new Date(
                    new Date(yk).setMonth(mk),
                ).toLocaleString('en-us', {month: 'long'})
            }},
            {{ new Date(yk).getFullYear() }}
            <div class="days">
                <div
                    :class="{ today: d.toDateString() === now.toDateString() }"
                    :key="dk + 'day'"
                    :style="{ width: dayWidth + 'px' }"
                    class="day"
                    v-for="(d, dk) in days[yk][mk]"
                >
                    <span class="theday" v-if="dayWidth > 25">
                        {{ d.getDate() }}
                    </span>
                    <span class="weekday" v-if="dayWidth > 25">
                        {{ d.toLocaleString('en-us', {weekday: 'short'}) }} 
                    </span>
                </div>
            </div>
        </div>
    </div>
</template>

可查看该组件的完整代码。

内容的提问来源于stack exchange,提问作者kolaente

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 09:48:02