简体   繁体   English

失败的道具类型:必须在容器上使用 Grid 的道具 justify

[英]Failed prop type: The prop justify of Grid must be used on container

在此处输入图像描述

I got the error while using Material-UI in react在反应中使用 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 uses CSS flexbox for layout. Grid使用 CSS flexbox 进行布局。 You cannot set alignItems in a Grid item, it must be placed in a Grid container.您不能在Grid项目中设置alignItems ,它必须放置在Grid容器中。 See this interactive example to know how to use alignItems in Grid .请参阅交互式示例以了解如何在Grid中使用alignItems

// invalid
<Grid container>
  <Grid item alignItems="center">
  </Grid>
</Grid>
// valid
<Grid container alignItems="center">
  <Grid item>
  </Grid>
</Grid>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MUI v5:失败的道具类型:`Grid` 的道具`direction` 只能与`container` 道具一起使用 - MUI v5: Failed prop type: The prop `direction` of `Grid` can only be used together with the `container` prop 如何修复“失败的道具类型:`grid` 的属性`spacing` 必须用于`container`? - How to fix "Failed prop type: The property `spacing` of `grid` must be used on `container`? 失败的道具类型:提供给“ForwardRef(Grid)”的无效道具“children” - Failed prop type: Invalid prop `children` supplied to `ForwardRef(Grid)` 失败的道具类型:提供给“ForwardRef(Grid)”的无效道具“lg” - Failed prop type: Invalid prop `lg` supplied to `ForwardRef(Grid)` 警告:失败的道具类型:游戏:道具类型`游戏`无效; 它必须是一个函数,通常来自React.PropTypes - Warning: Failed prop type: Game: prop type `game` is invalid; it must be a function, usually from React.PropTypes 警告:失败的道具类型:提供给“ForwardRef(网格)”的无效道具“xs” - 材质 UI 网格中的错误 - Warning: Failed prop type: Invalid prop `xs` supplied to `ForwardRef(Grid)` - Error in Material UI Grid 失败的道具类型:聊天:道具类型`房间`无效; 它必须是一个函数,通常来自React.PropTypes - Failed prop type: Chat: prop type `room` is invalid; it must be a function, usually from React.PropTypes 失败的道具类型:提供给“重定向”的无效道具“到” - Failed prop type: Invalid prop `to` supplied to `Redirect` 道具类型失败:提供给Styled(Container)的类型为number的道具类型无效,预期对象 - Failed prop type: Invalid prop `style` of type `number` supplied to `Styled(Container)`, expected `object` 失败的道具类型:“值”必须在 InputRange 的“minValue”和“maxValue”之间 - Failed prop type: "value" must be in between "minValue" and "maxValue" at InputRange
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM