【发布时间】:2018-01-12 02:55:25
【问题描述】:
我正在尝试将本地图像的路径写入项目,它似乎向我展示了一个未定义的图像。
如您所见,我在 app.component.html 中 我想做
src="img/profile.png"
但在浏览器中出现此错误
profile.png Failed to load resource: the server responded with a status of 404 (Not Found)
我的路径有问题吗?
【问题讨论】:
-
您好 Adir,从您的屏幕抓取 src="img/profile.png" 路径不正确。所以尝试使用路径 src="img/portfolio/profile.png"。我希望这是你的解决方案
-
不,profile.png 不在投资组合中,它在 img 中
-
@MalathyVenkatesan 实际上我不认为它是 - 如果您仔细查看该文件夹没有展开。设置 src 时,我相信它与您的
index.html中的<base href>相关,您可以检查一下吗?您可能还想尝试按照the top answer to this question 的建议将其放入资产文件夹中 -
试试这个解决方案 src="/img/profile.png"