第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

FullCalendar 不顯示通過帶有動態(tài)“extraParams”參數(shù)的 JSON 獲取的事件

FullCalendar 不顯示通過帶有動態(tài)“extraParams”參數(shù)的 JSON 獲取的事件

江戶川亂折騰 2021-12-02 14:52:46
我在使用動態(tài)“extraParams”參數(shù)顯示通過 JSON 獲取的事件時遇到問題,如文檔中所述:var calendarEl = document.getElementById('calendar');calendar = new FullCalendar.Calendar(calendarEl, {...,events: {    url: '/getEvents',    method: 'POST',    extraParams: function() {        var combobox = document.getElementById('combobox');        var value = combobox.options[combobox.selectedIndex].value;        return {client: value};    },    failure: function(error) {        console.log(error);        alert("Error", "Unable to fetch events", "red");    },},...});calendar.render();在調(diào)試面板上,我可以看到 FullCalendar 發(fā)出的請求:XHR POST https://127.0.0.1:8443/getEvents有了這個參數(shù):client: Allstart: 2019-09-30T00:00:00Zend: 2019-11-11T00:00:00ZtimeZone: UTC和回應(yīng):{  "error": "",   "events": [    {      "allDay": 1,       "color": "blue",       "end": "2019-10-24T00:00:00.000Z",       "extendedProps": {        "company": "Company 1",         "state": "Active",         "type": "task"      },       "groupId": "48",       "id": 27,       "start": "2019-10-23T00:00:00.000Z",       "title": "Title 1",       "url": ""    },     {      "allDay": 1,       "color": "blue",       "end": "2019-11-07T00:00:00.000Z",       "endpoints": 0,       "extendedProps": {        "company": "All",         "description": "Description",         "creationDate": "2019-11-04",         "state": "Active",         "tecnology": "test",         "element": "test 1",         "type": "type 2",         "user": "user 1",         "version": "1.2"      },       "id": 76,       "start": "2019-11-04T00:00:00.000Z",       "title": "Title 2",       "url": ""    }  ]}但是 FullCalendar 不顯示這兩個接收到的事件。我不知道我做錯了什么。問候。
查看完整描述

1 回答

?
慕蓋茨4494581

TA貢獻1850條經(jīng)驗 獲得超11個贊

發(fā)生這種情況是因為您的服務(wù)器必須返回一個僅包含事件的簡單數(shù)組,而沒有其他任何內(nèi)容。您正在返回一個復雜的對象。FullCalendar 不知道如何解包您的對象并找到包含相關(guān)數(shù)據(jù)的“事件”屬性。


您需要簡單地返回:


[

 {

  "allDay": 1, 

  "color": "blue", 

  "end": "2019-10-24T00:00:00.000Z", 

  "extendedProps": {

    "company": "Company 1", 

    "state": "Active", 

    "type": "task"

  }, 

  "groupId": "48", 

  "id": 27, 

  "start": "2019-10-23T00:00:00.000Z", 

  "title": "Title 1", 

  "url": ""

 }, 

 {

  "allDay": 1, 

  "color": "blue", 

  "end": "2019-11-07T00:00:00.000Z", 

  "endpoints": 0, 

  "extendedProps": {

    "company": "All", 

    "description": "Description", 

    "creationDate": "2019-11-04", 

    "state": "Active", 

    "tecnology": "test", 

    "element": "test 1", 

    "type": "type 2", 

    "user": "user 1", 

    "version": "1.2"

  }, 

  "id": 76, 

  "start": "2019-11-04T00:00:00.000Z", 

  "title": "Title 2", 

  "url": ""

 }

]

從您的服務(wù)器,沒有它的其余部分。


我必須說 fullCalendar 文檔并沒有特別清楚地說明這一事實。


注意,我認為“錯誤”屬性無論如何都是多余的,在任何 JSON 響應(yīng)中。如果出現(xiàn)錯誤,您應(yīng)該返回一個指示錯誤性質(zhì)的 HTTP 狀態(tài)代碼,以及一個完全不同的響應(yīng)正文,指示您想告訴用戶有關(guān)錯誤的任何內(nèi)容。這將在您的 JS 中觸發(fā)“失敗”回調(diào),并允許瀏覽器代碼做出適當?shù)捻憫?yīng)。


查看完整回答
反對 回復 2021-12-02
  • 1 回答
  • 0 關(guān)注
  • 286 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號