首页 > 解决方案 > 使用全日历“事件作为函数”(在 Vue 中)并返回一个承诺在更新资源时不会填充事件?

问题描述

我正在通过设置根据更改的选择元素更新资源列表,this.calendarOptions.resources并且我还使用函数来获取事件。

当我将这些东西结合起来时,资源会显示出来,并且似乎会获取事件,但它们不会显示在时间轴中。我也在calendarAPI.refetchEvents()更新资源后尝试过,看看是否有什么不同。事件已获取,但仍不显示。

如果我修复资源而不更新它,日历事件将成功显示。

任何可能发生这种情况的想法都非常感谢。

calendarOptions: {
    resources: [],
    events: this.getEvents
...
}

获取事件:

async getEvents(info) {
    try {
        const response = await this.$http.get(myurl)
        return response.data.bookings
    } catch (e) {
        console.log(e)
    }
}

获取资源:

async getResources() {
    try {
        const response = await this.$http.get(myresourceurl)
        this.calendarOptions.resources = response.data.resources
    } catch (e) {
        console.log(e)
    }
}
111

标签: javascriptvue.jsfullcalendarfullcalendar-5

解决方案


道歉。原来资源的 API 返回的是“resourceId”而不是“id”


推荐阅读