我是 Angular 的新手。我最近向 Github Pages 部署了一个示例网页。我已成功部署,但未显示在本地主机上可见的图像。相反,我在控制台上记录了 404。
这是包含 img
的组件:
home.component.html :
<div>
<img src='assets/images/birthday.jpg' alt='Happy Birthday' width="385px"/>
</div>
我的目录结构是:
|src
|--app
|--assets
|---images
|----birthday.jpg
dist
文件夹中的目录结构是:
|dist
|--happy-birthday
|--assets
|---images
|----birthday.jpg
我正在使用 angular-cli-ghpages
包进行部署。我的 Angular 版本是 10.0.14
。
最佳答案
尝试使用/assets/images/birthday.jpg
。
关于javascript - 部署到 Github Pages 后不显示 Angular 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63664818/