This article is a mirror article of machine translation, please click here to jump to the original article.

View: 2829|Reply: 0

[Angular] Angular 18 image static resource loading issue

[Copy link]
Posted on 7/23/2024 8:47:59 AM | | | |
Requirements: I created a v18 project using angular-cli, manually created the src/assets folder, and put in an image, and found that it could not be accessed, and reported a 404 error.

File Path:src/assets/test.png
img code:<img src="assets/test.png">

An online search found that the file structure of the v18 version has changed, as shown in the figure below:



D:\360Downloads>tree ng17
The folder PATH list for the volume Data
The volume serial number is AA1B-3F2F
D:\360DOWNLOADS\NG17
├─.vscode
└─src
    ├─app
    └─assets

D:\360Downloads>tree ng18
The folder PATH list for the volume Data
The volume serial number is AA1B-3F2F
D:\360DOWNLOADS\NG18
├─.vscode
├─public
└─src
    └─app
I recreated them using Angular CLI: 18.1.1, Angular CLI: 17.3.8 respectively, and the command is as follows:

I found that the v18 version no longer has the assets folder, but the public folder.

solution

Clip the assets folder to the public folder.

Reference:

The hyperlink login is visible.
The hyperlink login is visible.





Previous:2024 Python Silicon Valley Software + Tutorials + Courseware
Next:Two or three things about Shared Memory
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com