MUI-Datatable:显示数据显示此错误无法读取未定义的属性(读取'split')
MUI-Datatable: Displaying the data shows this error Cannot read properties of undefined (reading 'split')
当我在MuiDatatable
里面添加data
时,会显示这个错误
Cannot read properties of undefined (reading 'split')
如何解决此问题并显示数据?
我在 codesandbox 中重现了这个问题:
https://codesandbox.io/s/xenodochial-fog-s984v0?file=/src/App.js
代码:
export default function App() {
console.log(data);
const columns = [
{
name: "id",
label: "System ID", //or the order ID here
options: {
filter: true,
sort: true,
display: false
}
},
{
label: "Name",
options: {
filter: true,
sort: true
}
},
{
label: "Address",
options: {
filter: true,
sort: true
}
},
{
label: "Cart Items",
options: {
filter: true,
sort: true
}
},
{
label: "Total Amount",
options: {
filter: true,
sort: true
}
}
];
const options = {
filter: true,
selectableRows: "none",
responsive: "simple"
// onRowClick: handleRowClick,
};
return (
<div className="App">
<ThemeProvider theme={createTheme()}>
{" "}
<MUIDataTable
title={"Reports"}
options={options}
columns={columns}
data={data}
/>
</ThemeProvider>
</div>
);
}
你的数据在哪里定义的?请确保数据是一个对象数组,其结构为 table.
的列数组
当我在MuiDatatable
里面添加data
时,会显示这个错误
Cannot read properties of undefined (reading 'split')
如何解决此问题并显示数据?
我在 codesandbox 中重现了这个问题: https://codesandbox.io/s/xenodochial-fog-s984v0?file=/src/App.js
代码:
export default function App() {
console.log(data);
const columns = [
{
name: "id",
label: "System ID", //or the order ID here
options: {
filter: true,
sort: true,
display: false
}
},
{
label: "Name",
options: {
filter: true,
sort: true
}
},
{
label: "Address",
options: {
filter: true,
sort: true
}
},
{
label: "Cart Items",
options: {
filter: true,
sort: true
}
},
{
label: "Total Amount",
options: {
filter: true,
sort: true
}
}
];
const options = {
filter: true,
selectableRows: "none",
responsive: "simple"
// onRowClick: handleRowClick,
};
return (
<div className="App">
<ThemeProvider theme={createTheme()}>
{" "}
<MUIDataTable
title={"Reports"}
options={options}
columns={columns}
data={data}
/>
</ThemeProvider>
</div>
);
}
你的数据在哪里定义的?请确保数据是一个对象数组,其结构为 table.
的列数组