反应路线相对文件路径
我在组件中导入图像源,并且在本地机器上工作正常。但是,当我将站点上传到服务器时,找不到图像,并且显示出损坏的路径。在路由我的本地计算机上,路径为http:// localhost:3000/static/sedial/myimage.svg
在远程服务器上,它是http:http:http:http:http: //remoteserver.com/about/static/media/myimage.svg
。这是代码:
import myImage from '../assets/myImage.svg';
...
<img src={myImage} />
I'm importing an image source in a component and it's working fine on my local machine. But when I upload the site to my server the images cannot be found anymore and it shows a broken path. On the route about
my local machine the path is http://localhost:3000/static/media/myImage.svg
on the remote server it is http://remoteserver.com/about/static/media/myImage.svg
. Here's the code:
import myImage from '../assets/myImage.svg';
...
<img src={myImage} />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作:
Try this :