繁体   English   中英

部署到 Github Pages 后不显示角度图像

[英]Angular image not showing after deploying to Github Pages

我是 Angular 的新手。 我最近向 Github Pages 部署了一个示例网页。 我已成功部署,但未显示在本地主机上可见的图像。 相反,我在控制台上登录了 404。

这是包含img的组件:

主页.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

尝试明确给出一个相对路径( img相对于home.component.html路径)下面给出了一个例子,但是这可能会根据您的目录结构而改变。

<div><img src='../assets/images/birthday.jpg' alt='Happy Birthday' width="385px"/></div>

我只是尝试不使用前导斜杠,它起作用了: src='assets/images/birthday.jpg'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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