reactjs - 失败的道具类型:必须在容器上使用 Grid 的道具 justify
问题描述
在反应中使用 Material-UI 时出现错误
<Grid container justify="center">
<Box className={classes.box}>
<Grid item className={classes.item1}>
<Typography variant="h5" className={classes.loginTitle}>
Login
</Typography>
<Typography variant="body1" className={classes.subTitle}>
to continue to Program
</Typography>
</Grid>
{renderForm(window.location.pathname)}
<Grid
item
className={classes.component}
alignItems="center"
justify="space-between"
>
<Typography
variant="body2"
color="primary"
className={classes.createAccountLink}
>
<Link
style={{ cursor: "pointer" }}
onClick={(e) => e.preventDefault()}
>
Create account
</Link>
</Typography>
<Button
variant="contained"
color="primary"
disableElevation
className={classes.btn}
>
Login
</Button>
</Grid>
解决方案
Grid
使用 CSS flexbox 进行布局。您不能设置alignItems
在一个Grid
项目中,它必须放在一个Grid
容器中。请参阅此交互式示例以了解如何alignItems
在
Grid
.
// invalid
<Grid container>
<Grid item alignItems="center">
</Grid>
</Grid>
// valid
<Grid container alignItems="center">
<Grid item>
</Grid>
</Grid>
推荐阅读
- html - 使用 pandoc 将 html 转换为 json
- python - Scrapy + Python + Xpath : datapoint couldn't be scraped always
- c++ - 我可以在构造函数的主体中转发构造吗?
- octopus-deploy - 如何使用输出变量替换配置文件中的变量
- android - 如何增加admob收入
- c# - c#文本框数据绑定日期格式
- reactjs - 如何在我的反应项目中使用“酶”和“笑话”测试使用“超级代理”的异步操作?
- php - 在mysql中锁定具有多个用户的表
- r - 如何在 R 中使用 dplyr 进行条件选择?
- python-3.x - 如何在 python 中计算图像的 4 X 4 齐次变换矩阵