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,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,5],2:[1,2]