Reactjs 如何定位物料界面表左侧的列和右侧的数据以进行反应

Reactjs 如何定位物料界面表左侧的列和右侧的数据以进行反应,reactjs,position,Reactjs,Position,在演示和本文档中,我所能看到的就是这个表单中的表格 |列|列|列| |--数据--|--数据--|--数据--| 使用React(列位于左侧,数据位于右侧)创建材质UI表的方法是什么 |列|--|数据| |列|--|数据| |列|--|数据|我发现flexBox的某些功能虽然不理想,但有效(它基于物料文档中的沙盒代码): 从'@materialui/core/styles'导入{makeStyles}; 从“@material ui/core/Table”导入表格; 从“@material ui

在演示和本文档中,我所能看到的就是这个表单中的表格

|列|列|列|
|--数据--|--数据--|--数据--|

使用React(列位于左侧,数据位于右侧)创建材质UI表的方法是什么

|列|--|数据|
|列|--|数据|

|列|--|数据|

我发现flexBox的某些功能虽然不理想,但有效(它基于物料文档中的沙盒代码):

从'@materialui/core/styles'导入{makeStyles};
从“@material ui/core/Table”导入表格;
从“@material ui/core/TableBody”导入表体;
从“@material ui/core/TableCell”导入TableCell;
从“@material ui/core/TableContainer”导入TableContainer;
从“@material ui/core/TableRow”导入TableRow;
从“@material ui/core/Paper”导入纸张;
const useStyles=makeStyles({
表:{
最小宽度:650,
显示:“flex”
},
桌面:{
显示:“flex”,
flexDirection:“列”,
},
表体:{
显示:“flex”,
},
tableRow:{
显示:“flex”,
flexDirection:“列”
}
});
函数createData(名称、卡路里、脂肪、碳水化合物、蛋白质){
返回{名称、卡路里、脂肪、碳水化合物、蛋白质};
}
常量行=[
createData(“冷冻酸奶”,159,6.0,24,4.0),
createData(“冰淇淋三明治”,237,9.0,37,4.3),
createData('Eclair',262,16.0,24,6.0),
createData('Cupcake',305,3.7,67,4.3),
createData('Gingerbread',356,16.0,49,3.9),
];
导出默认函数BasicTable(){
const classes=useStyles();
返回(
甜点(100克)
卡路里
脂肪(g)
碳水化合物(克)
蛋白质(g)
{rows.map((row)=>(
{row.name}
{row.carries}
{row.fat}
{row.carbs}
{row.protein}
))}
);
}

我发现flexBox的某些功能并不理想,但很有效(它基于物料文档中的沙盒代码):

从'@materialui/core/styles'导入{makeStyles};
从“@material ui/core/Table”导入表格;
从“@material ui/core/TableBody”导入表体;
从“@material ui/core/TableCell”导入TableCell;
从“@material ui/core/TableContainer”导入TableContainer;
从“@material ui/core/TableRow”导入TableRow;
从“@material ui/core/Paper”导入纸张;
const useStyles=makeStyles({
表:{
最小宽度:650,
显示:“flex”
},
桌面:{
显示:“flex”,
flexDirection:“列”,
},
表体:{
显示:“flex”,
},
tableRow:{
显示:“flex”,
flexDirection:“列”
}
});
函数createData(名称、卡路里、脂肪、碳水化合物、蛋白质){
返回{名称、卡路里、脂肪、碳水化合物、蛋白质};
}
常量行=[
createData(“冷冻酸奶”,159,6.0,24,4.0),
createData(“冰淇淋三明治”,237,9.0,37,4.3),
createData('Eclair',262,16.0,24,6.0),
createData('Cupcake',305,3.7,67,4.3),
createData('Gingerbread',356,16.0,49,3.9),
];
导出默认函数BasicTable(){
const classes=useStyles();
返回(
甜点(100克)
卡路里
脂肪(g)
碳水化合物(克)
蛋白质(g)
{rows.map((row)=>(
{row.name}
{row.carries}
{row.fat}
{row.carbs}
{row.protein}
))}
);
}

谢谢,这对我帮助很大。由于我对css的东西不是很有天赋,你能确保表格占据整个空间吗?经过几次测试,我发现了这个解决方案:谢谢你,它帮了我很多。由于我对css的东西不是很有天赋,你能确保表格占据整个空间吗?经过几次测试,我发现了这个解决方案:
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 TableContainer from '@material-ui/core/TableContainer';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';

const useStyles = makeStyles({
table: {
 minWidth: 650,
 display: "flex"
},
tableHead: {
 display:"flex",
 flexDirection:"column",
},
tableBody: {
 display:"flex",

},
tableRow: {
 display:"flex",
 flexDirection:"column"
}
 
});

function createData(name, calories, fat, carbs, protein) {
return { name, calories, fat, carbs, protein };
}

const rows = [
createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
createData('Eclair', 262, 16.0, 24, 6.0),
createData('Cupcake', 305, 3.7, 67, 4.3),
createData('Gingerbread', 356, 16.0, 49, 3.9),
];

export default function BasicTable() {
const classes = useStyles();

return (
 <TableContainer component={Paper}>
   <Table className={classes.table} aria-label="simple table">
   <TableRow className={classes.tableHead}>
 
         <TableCell>Dessert (100g serving)</TableCell>
         <TableCell align="right">Calories</TableCell>
         <TableCell align="right">Fat&nbsp;(g)</TableCell>
         <TableCell align="right">Carbs&nbsp;(g)</TableCell>
         <TableCell align="right">Protein&nbsp;(g)</TableCell>
       </TableRow>
         <TableBody className={classes.tableBody}>
   
       {rows.map((row) => (
         <TableRow  className={classes.tableRow} key={row.name}>
           <TableCell component="th" scope="row">
             {row.name}
           </TableCell>
           <TableCell align="right">{row.calories}</TableCell>
           <TableCell align="right">{row.fat}</TableCell>
           <TableCell align="right">{row.carbs}</TableCell>
           <TableCell align="right">{row.protein}</TableCell>
         </TableRow>
       ))}
     </TableBody>
   </Table>
 </TableContainer>
);
}