![](/img/trans.png)
[英]Failed prop type: The prop justify of Grid must be used on container
[英]How to fix "Failed prop type: The property `spacing` of `grid` must be used on `container`?
我目前正在做一個項目,在這個項目中我使用了 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
道具。 我還嘗試從 Grid 項目中刪除間距,這會導致更多錯誤。
<BrowserRouter>
<AppBar position="static">
<Toolbar style={navStyle}>
<Grid
justify="space-between"
container
spacing={10}
>
<Grid
item
spacing={2}
>
...
然而,一切都正確地顯示在屏幕上; 這個錯誤仍然彈出。 我不確定如何解決這個問題,很想學習!
似乎也有一些關於Grid 的困惑也吸引了我;
容器
物品
但是您可以完全使用 Item & Container...
<Grid container item xs={12} spacing={3}>
....
</Grid>
刪除spacing={2}
要使用spacing
您可以嘗試 ``containers
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.