我正在尝试将数据存储在名为__parsed_extra
的属性中(参见图片):
这是我的代码:
import React, { Component } from "react";
import Papa from "papaparse";
export default class Player extends Component {
constructor(props) {
super(props);
this.state = {
data: []
};
this.updateData = this.updateData.bind(this);
}
UNSAFE_componentWillMount() {
var csvFilePath = require("./training13Sep.csv");
Papa.parse(csvFilePath, {
header: true,
skipEmptyLines: true,
download: true,
complete: this.updateData
});
}
updateData(result) {
const data = result.data;
this.setState({ data: data });
console.log(this.state.data);
}
render() {
console.log(this.state.data[15].__parsed_extra[1]);
return (
<table>
<tr>
<th>Player</th>
<th>Nationality</th>
<th>Age</th>
<th>Player Number</th>
<th>Signed</th>
<th>Wage</th>
<th>Position</th>
<th>Description</th>
<th>Height</th>
<th>Weight</th>
<th>Social Networks</th>
</tr>
</table>
);
}
}
我收到错误消息:
TypeError:无法读取未定义的属性'__parsed_extra'
怎么了?