javascript - 部署到 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
.
解决方案
尝试使用/assets/images/birthday.jpg
.
推荐阅读
- swift - 选择 UITextField 文本时隐藏选项菜单
- java - 接口,所有方法都必须是抽象的,但是一个呢?
- windows - 如何在 Windows 上自动将所有 .dll 依赖项复制到 .exe 文件夹中?
- java - 为什么这个 do-while 语句打印 20?
- node.js - Node JS - 如何等到Google Cloud Storage Bucket上存在文件,然后下载文件
- css - Bootstrap 4 - 如何正确居中 Div(表单)?
- python - pandas Series.map() 的内部实现是什么?
- go - 为什么要自动构建/安装更新所需的软件包?
- mysql - 比较大文本字段是否相等
- azure - “az ad app permission add ...”的 terraform 等价物是什么?