图像 src 在主页以外的其他页面中时中断



我的图像位于

images/icons/artist_default.png

因此,当我在主页上时,会显示图像,如果我看到路径,它看起来像这样:

http://localhost:7777/images/icons/artist_default.png

但是,在像这样的用户页面中,http://localhost:7777/user/giorgio-martini它会中断,路径如下所示:

http://localhost:7777/user/images/icons/artist_default.png

如您所见,它错了,它在它之前添加了 users 参数......所以它中断了。

我不知道如何解决这个问题,我不应该添加一个完整的路径,感觉不对......但是,我如何将img指向正确的位置呢?

谢谢

以斜杠('/'(开头的图像源。这意味着它将始终从基本路径开始。而不是

<img src="images/icons/artist_default.png">

用这个,

<img src="/images/icons/artist_default.png">

最新更新