如何在对象jsx中返回变量



请使用>gt>。目前的代码是这样的:

tableData() {
const filteredEvents = this.props.graphData.events.filter((event) =>
moment(event.eventDate).isBetween(this.startMoment, this.endMoment)
);
const eventsByM = _.groupBy(filteredEvents, (event) => event.metadata.mId);
const tableRows = Object.values(eventsByM).map((events) => {
const firstEvent = events[0];
return ({
>>>     "Mentee Name": firstEvent.modalData.menteeName,
"Mentor Name": firstEvent.modalData.mentorName,
"Conversations Logged": events.length,
tableRowUrl: firstEvent.modalData.tableRowUrl,
});
});
return tableRows;
}

我想做一根";被代理人姓名;一个变量,但jsx没有将其作为变量读取。我该怎么做?我这样试过,但它实际上读起来是";menteeName":

tableData() {
const filteredEvents = this.props.graphData.events.filter((event) =>
moment(event.eventDate).isBetween(this.startMoment, this.endMoment)
);
const eventsByM = _.groupBy(filteredEvents, (event) => event.metadata.mId);
const tableRows = Object.values(eventsByM).map((events) => {
const firstEvent = events[0];
const menteeName = "Apprentice name";
return ({
>>>    menteeName: firstEvent.modalData.menteeName,
"Mentor Name": firstEvent.modalData.mentorName,
"Conversations Logged": events.length,
tableRowUrl: firstEvent.modalData.tableRowUrl,
});
});
return tableRows;
}

您可以使用变量作为对象键,如下所示:

[menteeName]: firstEvent.modalData.menteeName

相关内容

  • 没有找到相关文章

最新更新