Material-UI CardMedia图像未显示 [英] Material-UI CardMedia image not showing

查看:58
本文介绍了Material-UI CardMedia图像未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将样式应用到 CardMedia,但图像仍未显示

I've applied the styling on to CardMedia but the image still doesn't show

<CardMedia 
    style = {{ height: 0, paddingTop: '56.25%'}}
    image={thread.url}
    title={thread.title}
/>

thread.url只是图像的链接,所以我认为它应该可以工作我做对了还是有其他显示图像的方式?

thread.url is just a link to the image, so I believe it should be working Am I doing it correctly or is there a different way to show the image?

推荐答案

如果使用create-reac-app,则意味着您可能还使用了Webpack.Webpack要求您使用以下命令指定所有依赖关系:

If you use create-reac-app it means you probably also use Webpack. Webpack requires you to specify all dpendencies using:

import imageUrl from './image.jpg'

然后您可以按以下方式使用它:

And then you can use it as following:

image={imageUrl}

您可以找到有关将Webpack与Create React App一起使用的更多信息此处

You can find more information about using Webpack with Create React App here

这篇关于Material-UI CardMedia图像未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆