简体   繁体   English

部署在 Heroku 上时,图像未加载到 React 应用程序中

[英]Images not loading in React app when deployed on Heroku

I'm a new React developer attempting to deploy my first React app on Heroku.我是一名新的 React 开发人员,试图在 Heroku 上部署我的第一个 React 应用程序。

All the images load fine locally, but no longer load when deployed on Heroku.所有图像在本地都可以正常加载,但在部署到 Heroku 时不再加载。

Here is the link to my site: https://yom-recipes.herokuapp.com/这是我网站的链接: https://yom-recipes.herokuapp.com/

Each box is supposed to load an image dynamically from a prop link passed over from another component.每个盒子都应该从另一个组件传递的道具链接动态加载图像。

The images are located in a folder within src.图像位于 src 中的文件夹中。

<img src={require(`../images/${props.link}.jpg`)} alt={props.name}/>

Any insight deeply appreciated, thanks!任何见解都非常感谢,谢谢!

.btn-note img {
    display: block;
    position: relative;
    top: -5px;
    text-align: center;
    width: 220px;
    border-radius: 12px;
    margin-bottom: -25%;
    overflow: hidden;
    /* opacity: 1%; */ comment here
    z-index: 1;
}

remove opacity style to show your image删除不透明样式以显示您的图像

Increase your opacity增加不透明度

.btn-note img {
    display: block;
    position: relative;
    top: -5px;
    text-align: center;
    width: 220px;
    border-radius: 12px;
    margin-bottom: -25%;
    overflow: hidden;
    opacity: 100%;
    z-index: 1;
}

instead of opacity: 1%;, increase it to 100%而不是不透明度:1%;,将其增加到 100%

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

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