[英]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: 必须指定
children
、 image
、 src
或component
道具。 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.