如何在开发阶段从角度项目外部提供 img src 路径



>我正在尝试从角度项目外部提供img src路径,请尽快解决我的问题。 我的文件夹结构看起来像

ProjectName
backend
assets
imagestest.png
angularprojectroot
app
src
component files

在文件路径中,您可以使用..

<img src="../../../../backend/assets/images/test.png" />

绝对仅用于开发。在生产环境中.png从您的服务器提供服务。

在您的特定情况下,使用 angular.json 将其添加到您的资产中:

// assets is an array. Keep the other items in the array but add the one displayed below
"assets": ["../../../backend/assets/images/test.png"]

那么我相信你可以把图像称为测试.png:

<img src="test.png" />

最新更新