简体   繁体   English

失败的道具类型:Material-UI:必须指定孩子、图像、src 或组件道具。 在 CardMedia

[英]Failed prop type: Material-UI: Either children, image, src or component prop must be specified. at CardMedia

I'm trying to use CardMedia component from Material-ui and and was getting this error ' Failed prop type: Material-UI: Either children , image , src or component prop must be specified.我正在尝试使用 Material-ui 中的 CardMedia 组件,并且收到此错误“道具类型失败:Material-UI: 必须指定childrenimagesrccomponent道具。 at CardMedia ' tried many solution like adding component='img' it removed the error but the image wasn't displayed (removes the error but breaks it).在 CardMedia '尝试了许多解决方案,例如添加 component='img' 它删除了错误但未显示图像(删除错误但破坏了它)。 it works fine with out it tho but i want to know why i kept getting the error没有它它工作正常,但我想知道为什么我一直收到错误

"@material-ui/core": "4.12.3", "@material-ui/core": "4.12.3",
"@material-ui/icons": "^4.11.2", "@material-ui/icons": "^4.11.2",
"react": "^17.0.2", “反应”:“^17.0.2”,

 <CardMedia className={media} image={post.selectedFile} title={post.title} // component="image" // component="img" />

After some Debugging found out that the CardMedia component is a Div and my styles were implied on a div and specifying it as an image component using the line component="img", it broke my css, and the image was just 'Hiding lol' it was there all along.经过一些调试发现 CardMedia 组件是一个 Div 并且我的 styles 隐含在一个 div 上并使用行 component="img" 将其指定为图像组件,它破坏了我的 css,图像只是“隐藏哈哈”它一直都在那里。

暂无
暂无

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

相关问题 失败的道具类型:Material-UI:必须指定“children”、“image”、“src”或“component”道具 - Failed prop type: Material-UI: Either `children`, `image`, `src` or `component` prop must be specified (Material-ui / React)道具类型失败:提供给GridList的道具“ cellHeight”无效 - (Material-ui / React) Failed prop type: Invalid prop `cellHeight` supplied to `GridList` 我在材质 UI 选项卡中有错误为“道具类型失败:不支持道具`children`。 请删除” - I have error in material UI tabs as “Failed prop type: The prop `children` is not supported. Please remove it” 图像未显示在 material-ui CardMedia 元素中 - Image not displaying in material-ui CardMedia element material-ui中Drawer组件中container prop的作用 - what does container prop do in the Drawer component in material-ui 必须为 Field(auto) 指定渲染道具、渲染函数或组件道具 - Must specify either a render prop, a render function as children, or a component prop to Field(auto) react material-ui CardMedia 组件中的自动播放视频 - Autoplay video in react material-ui CardMedia component 有条件地使用 material-ui 默认道具 - Conditionally use material-ui default prop Material UI - 提供给 ButtonBase 的 `component` 道具无效。 请确保在此自定义组件中呈现 children 道具 - Material UI - The `component` prop provided to ButtonBase is invalid. Please make sure the children prop is rendered in this custom component 确定反应 Material-ui CardMedia 的图像文件大小 - determining image file size of a react Material-ui CardMedia
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM