我有这个元素在我的index.cshtml页:为什么我在客户端出现错误`无法加载资源`?
<section class="parallax parallax-2 padding-xxs" style="background-image: url('mySiteName/assets/images/shutterstoc/img1.jpg');">
<div>some content </div>
</section>
正如你可以看到我有样式属性。
如果我改变风格属性,这一点:
style="background-image: url('~/assets/images/shutterstoc/img1.jpg');"
的背景图像消失,我得到这个错误在Web控制台:
Failed to load resource: the server responded with a status of 404 (Not Found) img1.jpg
**更新*
The path to the image is:
http://localhost/assets/images/shutterstoc/img1.jpg
As you can see the mySiteName is missing.
更新2: 我试试这个路径:
<section class="parallax parallax-2 padding-xxs" style="background-image: url('./assets/images/img1.jpg')">
但我仍然得到上面的错误。 为什么我得到错误Failed to load resource
以及如何解决它?
为什么'〜'而不是'.'? –
只是使用'。 '而不是 –
点的意义是什么? – Michael