【发布时间】:2023-03-19 08:20:02
【问题描述】:
import React, {Component} from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
const useStyles = makeStyles({
root: {
width: '100%',
overflowX: 'auto',
},
table: {
minWidth: 650,
},
});
function createData(data1, data2, data3) {
return {data1, data2, data3, };
}
export default function SimpleTable(props) {
let rowval= props.values;
let rows = createData(rowval)
const classes = useStyles();
return (
<Paper className={classes.root}>
<Table className={classes.table} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>data1</TableCell>
<TableCell align="right">data2</TableCell>
<TableCell align="right">data3</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map(row => (
<TableRow key={row.data1}>
<TableCell component="th" scope="row">
{row.data1}
</TableCell>
<TableCell align="right">{row.data2}</TableCell>
<TableCell align="right">{row.data3}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Paper>
);
}
我收到以下错误:
react-dom.development.js?61bb:21810 The above error occurred in the <SimpleTable> component:
in SimpleTable (created by Search)
in div (created by Search)
in Search (created by App)
in div (created by App)
in App
我想知道如何实现这一点,任何参考都将不胜感激,请从 props.values 的 api 数据中找到示例动态 从子组件 值 0:[1,2,3],1:[1,2,5],2:[1,2,2]
【问题讨论】:
-
您发布了错误的堆栈跟踪,实际的错误信息是什么?
标签: reactjs material-ui react-table