[英]Why is Image not showing in angular home component project?
我正在处理一个 angular 项目,但试图将图像添加到 html 组件中的表行。 图像未显示,我尝试了多种方法使其正常工作,但仍然无法显示。 这是 home.component.html 代码:
图像位于 e2e 文件夹下项目文件夹中名为“images”的文件夹中,位于 node_modules 文件夹之上
<table>
<tr>
<td>
<img src="images/Larissa.jpg" alt="investor1">
<p>"Trusted and quick profit. I use this website many times and I recommend it."</p>
</td>
<td>
<img src="images/petroski.jpg" alt="investor2">
<p>"I feel safe with the knowledge that my investment is secured and safe with Coin Rush."</p>
</td>
<td>
<img src="images/marie.jpg" alt="investor3">
<p>"Thank you i am very impressed”</p></td>
</tr>
</table>
图像是从那些设置为静态的文件夹中加载的,或者我们可以说是assets
文件夹。 如果要加载特定资源,则必须将该资源放在 assets 下。
"assets": [
"src/assets"
],
如果要创建新文件夹,请在angular.json
中的angular.json
下提供该文件夹路径。
并提供从您的文件夹开始的相对路径。 例如,
Your image is under the path src/assets/images/1.jpg
然后你需要提供路径作为
<img src="assets/images/1.jpg">
e2e 文件夹不是公用文件夹。 它将被 e2e 测试使用。 您可以通过端到端测试 (E2E) 进行谷歌搜索。 https://coryrylan.com/blog/introduction-to-e2e-testing-with-the-angular-cli-and-protractor
您必须添加一个名为assets
的目录,在此目录中您可以存储项目中所需的所有图像,要使用这些图像,您必须在图像标签的src
属性中提供图像的相对路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.