如何提供资产文件夹之外的图像?

时间:2020-04-29 06:46:53

标签: angular

my assets config in angular json

我用于访问根目录映像的代码

Preview image of my code


我的文件夹结构

preview of my angular app folder structure


当我尝试访问那些外面的图像时遇到的错误

Error

1 个答案:

答案 0 :(得分:0)

想象一下在ts文件中有一个这样的变量:

public myImage = "something.png";

在html中,以尝试使用的方式加载图像,只需执行以下操作即可:

<img [src]="'./assets/' + myImage">