简体   繁体   English

GridTile(Material-ui)不显示图像

[英]GridTile (Material-ui) doesn't display images

class App extends Component {

render(){
    return (
        <div className="App">
            <MuiThemeProvider>
                <div>
                    <GridList cellHeight={100}>
                        {this.props.data.map((cat) => (
                        <GridTile key={cat.photo} title={cat.title}>
                            {console.log(cat.photo)}
                            <img src={cat.photo} alt={cat.photo}/>
                        </GridTile>))}
                        <GridTile key="wiam.jpg" title="joijoiji">
                            <img src="wiam.jpg"/>
                        </GridTile>
                    </GridList>
                </div>
            </MuiThemeProvider>
        </div>
    );
}

} }

"wiam.jpg" is a picture that I copied in my entire project folder, yet it doesn't display, but when I use an absolute link to a picture on a external website, I have no issue. “ wiam.jpg”是我复制到整个项目文件夹中的图片,但没有显示,但是当我使用指向外部网站上图片的绝对链接时,没有任何问题。

Where am I supposed to put the image on my server for it to appear ? 我应该将图像放在服务器的什么位置才能显示?

I had a similar problem. 我有一个类似的问题。 Images in material-ui components are distributed from the "public" directory. material-ui组件中的图像是从“公共”目录中分发的。 So if you have /public/images/wiam.jpg , src="images/wiam.jpg" should display the image correctly. 因此,如果您具有/public/images/wiam.jpg ,则src="images/wiam.jpg"应该正确显示图像。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM