[英]Can't load local image in my Mean-stack app
So I have an image I have stored in my app. 所以我有一个图像存储在我的应用程序中。 Now I have my home component and the initial idea was to use the image as the background of my Jumbotron.
现在,我有了家庭组件,最初的想法是将图像用作超大背景的背景。 I created an images folder inside my assets folder ( see project structure below ) and used the below code in my Scss file to load the image as a background:
我在资产文件夹中创建了一个图像文件夹(请参见下面的项目结构),并在我的Scss文件中使用以下代码将图像作为背景加载:
@import "../SCSS-partials/variables";
.jumbotron {
color: $theme-color-white;
font-style: 'Shift', sans-serif;
background-image: url("../images/home-jumbotron.jpg");
}
I used a relative path to the image file, but the image is not showing. 我使用了图像文件的相对路径,但是图像未显示。 Does anyone know why and how to fix this?
有谁知道为什么以及如何解决这个问题?
Home.component.html Home.component.html
<div class="home-page">
<div class="jumbotron jumbotron-fluid">
<div class="container-fluid">
<h1>Harry Potter: Wizards Unite Fanpage</h1>
<h3>Latest News and Tip & Tricks</h3>
</div>
</div>
<img src="../images/home-jumbotron.jpg" alt="fail">
</div>
Project Structure: 项目结构:
您必须将该路径添加到angular-cli.json的资产中,或仅将该图像放入资产文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.