所以我使用react-redux和webpack构建我的应用程序,它在本地运行没有任何问题。当我在heroku上部署应用程序时,图像没有显示,而是看到了一个破碎的图标。图像的路径应该是好的:
const imgPath = '../../style/imgs/cryptocurrency-icons/svg/color';
我没有收到任何与控制台中的图像相关的错误,它们只是无法加载。
这是我的项目:https://github.com/jorgeduardos/CryptoPrices
heroku应用程序:https://crypto-waatch.herokuapp.com/
发布于 2018-01-29 20:05:10
也许你必须像这样导入图片:
import someImage from '../../style/imgs/cryptocurrency-icons/svg/color'
然后是<img src= { someImage } />
发布于 2018-09-18 07:10:22
对我来说,问题是在做git push
的时候,git转换了行尾,这导致了损坏的图像数据。为了避免这种情况,我更改了.gitattributes
的配置,并添加了:*.png binary *.jpg binary *.jpeg binary *.gif binary *.ico binary *.mov binary *.mp4 binary *.mp3 binary *.flv binary *.fla binary *.swf binary *.gz binary *.zip binary *.7z binary *.ttf binary *.eot binary *.woff binary *.pyc binary *.pdf binary
它现在可以工作了:)
它在本地工作,因为你从你的机器上提供文件,而Heroku使用来自远程repo的文件,而远程repo中的图像被损坏。
https://stackoverflow.com/questions/48508326
复制相似问题