用>>>查看有问题的行。代码目前是这样的:
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;
}
而且我想让字符串“Mentee Name”成为一个变量,但 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;
}