首页 > 解决方案 > 部署到 Github Pages 后未显示 Angular 图像

问题描述

我是 Angular 的新手。我最近在 Github Pages 上部署了一个示例网页。我成功部署了,但是在 localhost 上可见的图像没有显示出来。相反,我在控制台上登录了 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.

标签: javascriptangulargithub-pages

解决方案


尝试使用/assets/images/birthday.jpg.


推荐阅读