reactjs - 如何在FullCalendar的反应js中附加和显示具有其他属性的标题?
问题描述
我想将标题与同一事件的名字和姓氏连接起来,因此事件标题显示为“夜班: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}
/>
解决方案
尝试像这样解构它
<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}`,
};
})}
/>;
推荐阅读
- java - 将 XML 导入 Excel 以模拟将 XML 文档“拖动”到 Excel
- java - Arraylist 输出被覆盖
- kubernetes - 将日期命令作为参数传递给 kubernetes cronjob
- postgresql - 排除具有空值的行
- javascript - 当我尝试为我的待办事项列表应用程序创建 LI 元素时,我的浏览器屏幕上没有显示任何内容
- tfs - 你可以在 TFS Build 中使用 MSpec 的“Tags”属性吗?
- android - Socket.io:“无法读取未定义的属性‘发射’”
- python - Box-Ljung 测试在 R 和 Python 中给出不同的 p 值
- asp.net-mvc - Telerik gird 编辑弹出窗口 - 使用 jQuery 更新其中一个字段时无法保存更改
- web-scraping - 需要从“https://sports.williamhill.com/betting/en-gb/in-play/football”中提取实时进球和剩余时间数据