gpt4 book ai didi

reactjs - 如何修复必须在 "Failed prop type: The property ` 上使用的 `grid` 的 `container` 间距?

转载 作者:行者123 更新时间:2023-12-03 20:27:51 35 4
gpt4 key购买 nike

我目前正在做一个项目,在这个项目中我使用了 React 和 Material-UI 框架。但是,使用 grid 后会弹出一个错误消息:

checkPropTypes.js:20 Warning: Failed prop type: The property `spacing` of `Grid` must be used on `container`.
in WithStyles(ForwardRef(Grid)) (created by NavBar)
in NavBar (created by Root)
in Root

我已经检查了我的所有代码,并且 Grid 容器确实使用了 spacing Prop 。
我还尝试从 Grid 项目中删除间距,这会导致更多错误。
<BrowserRouter>
<AppBar position="static">
<Toolbar style={navStyle}>
<Grid
justify="space-between"
container
spacing={10}
>
<Grid
item
spacing={2}
>
...

然而,一切都正确地显示在屏幕上;这个错误仍然弹出。我不确定如何解决这个问题,很想学习!

最佳答案

您不能在项目网格上放置间距 Prop 。

尝试删除 spacing={2}
并查看 Grid API MUI

spacing : Defines the space between the type item component. It can only be used on a type container component.

关于reactjs - 如何修复必须在 "Failed prop type: The property ` 上使用的 `grid` 的 `container` 间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57031580/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com