Cannot get relative image path in angular 6

谁说我不能喝 提交于 2019-12-02 12:58:54

At first you should move your assets like the img you use into the assets folder which is a direct child of src.

You should then be able to call the image directly by <img src="assets/images/01.jpg">

In your .angular.json you can define the glob as this one

"assets": [
    {"glob": "**/*", "input": "../../public", "output": "./assets/"}
]

This will copy the contents of your public folder to the /dist/assets/ directory. Then, use it like

<img src="assets/images/01.jpg">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!