简体   繁体   中英

images not showing up after build angular project

i have already finished coding my app and i try to build it to production mode ,and after testing the app , i see that images not showing in the app as logo ... but the the devloppement mode it's ok . this is the tree of my project :

you can see here the structure of the project in production mode

is it neccessary to add webpack to my project to solve this problem ?

i want also to ask you about the function of webpack , because my project is not including webpack and i found that is neccessary to have it my application .

Personally i don't even know what it is a webpack (and i'm not proud of it), but i know why you are having that issue.

You should take off the slash in the beginning of the images paths. So you have to use <img src="assets/image.png" and not <img src="/assets/image.png"

just to add on the @CybrRob 's answer.

Angular 在 assets 文件夹中查找图像,因此在您的 html 中,使用 <img src="assets/image.png" 不要包含“../”

just change your path from

<img src="../../assets/g5.jpg" alt="">

to

<img src="assets/g5.jpg"  alt="">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM