首页 > 解决方案 > Angular 8 Unable to access images in assets folder

问题描述

I'm unable to access the images available in the assets folder:

src
 |->app
 |->assets
    |->images
        |->image1.jpg
        |->image2.png

in app.component.html

src
 |->app
     |-> app.component.html

I'm trying to use these images

<img src="../assets/images/image1.jpg"/> <img src="../assets/images/image2.png"/>

Even I have added this in angular.json

"assets": [
              "src/favicon.ico",
              "src/assets",
              "src/assets/images/image1.jpg",
              "src/assets/images/image2.png"
            ],

images are showing like this:

enter image description here

Please let me how to fix it

Thanks in advance.

标签: angularangular-materialangular8

解决方案


尝试:

<img src="/assets/images/image1.jpg"/> <img src="/assets/images/image2.png"/>


推荐阅读