【问题标题】:How to append and display a title with other property of an even in react js of FullCalendar?如何在FullCalendar的反应js中附加和显示具有其他属性的标题?
【发布时间】:2020-09-15 11:38:24
【问题描述】:

我想将标题与同一事件的名字和姓氏连接起来 所以事件标题显示为“夜班:Rehan Bhai”

以下是我的活动:

{
        "_id": "5f607e0cc8ec5321c84f8a2d",
        "userId": {
            "_id": "5f5c8a7fcb2f483bf0f45062",
            "username": "Rehan Bhai",
            "firstName": "Rehan",
            "lastName": "Bhai",
            "email": "rehanuser@gmail.com",
            "partener": "yes",
            "type": "user",
            "pass": "$2a$10$zVT1vnJE6nhPq36hk1OJPuwBAxiqenP0sOt5LowdLFPNfqhUy2ZDi",
            "avatar": "//www.gravatar.com/avatar/8092a3d2de82f15929882914c7ad7781?s=200&r=pg&d=mm",
            "regDate": "2020-09-12",
            "__v": 0
        },
        "start": "2020-09-08",
        "end": "2020-09-08",
        "title": "Evening Shift",
        "color": "#25d818",
        "__v": 0
}

以下是我的代码:

<FullCalendar
    defaultView="dayGridMonth"
    plugins={[dayGridPlugin, interactionPlugin]}
  events={events}
  />

【问题讨论】:

    标签: reactjs fullcalendar title


    【解决方案1】:

    尝试像这样解构它

    <FullCalendar
      defaultView="dayGridMonth"
      plugins={[dayGridPlugin, interactionPlugin]}
      events={events.map((event) => {
        return {
          id: event._id,
          userId: event.userId,
          start: event.start,
          end: event.end,
          title: `${event.title}: ${event.userId.firstName} ${event.userId.lastName}`,
        };
      })}
    />;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-16
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 2019-07-19
      • 1970-01-01
      相关资源
      最近更新 更多