@Shroy已经回答了这个问题。但我一直在努力只添加
Right Border
如何仅在单元格的一侧添加边框。
const styles = theme => {
tableRightBorder : { borderWidth: 0, borderWidth: 1, borderColor: 'red',borderStyle: 'solid'}
}
...
class TableComponent ...
{ classes } = this.props;
<Table >
<TableHead>
<TableRow >
<TableCell>Column 1</TableCell>
<TableCell>Column 2</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell className={classes.tableRightBorder}>Cell 1</TableCell>
<TableCell>Cell 2</TableCell>
</TableRow>
</TableBody>
</Table>
export default withStyles(styles)(TableComponent)
看起来是这样的。
要获取上图的完整工作组件,请尝试下表
import React from 'react';
import PropTypes from 'prop-types';
import { makeStyles } from '@material-ui/styles';
import {
Table,
TableBody,
TableCell,
TableHead,
TableRow,
} from '@material-ui/core';
import { connect } from 'react-redux';
const useStyles = makeStyles(theme => ({
root: {},
tableRightBorder: {
borderWidth: 0,
borderRightWidth: 1,
borderColor: 'black',
borderStyle: 'solid',
},
}));
const DataTable = props => {
const classes = useStyles();
return (
<Table>
<TableHead>
<TableRow>
<TableCell>
Column 1
</TableCell>
<TableCell>Column 2</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell className={classes.tableRightBorder}>
Cell 1
</TableCell>
<TableCell>Cell 2</TableCell>
</TableRow>
</TableBody>
</Table>
);
};
DataTable.propTypes = {
className: PropTypes.string,
};
function mapStateToProps() {}
export default connect(mapStateToProps, {})(DataTable);