简体   繁体   English

为什么图像没有显示在角度家庭组件项目中?

[英]Why is Image not showing in angular home component project?

I am working on an angular project but trying to add an image to a table row in the html component .我正在处理一个 angular 项目,但试图将图像添加到 html 组件中的表行。 The image is not showing and I have tried many ways to make it work but still can't get it to show .图像未显示,我尝试了多种方法使其正常工作,但仍然无法显示。 Here is the home.component.html code :这是 home.component.html 代码:

The Images are in a folder named "images" in the project folder under the e2e folder , atop the node_modules folder图像位于 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>

Images are loaded from those folders which are set static or we can say assets folder.图像是从那些设置为静态的文件夹中加载的,或者我们可以说是assets文件夹。 If you want to load specific resource, then you must put that resource under assets.如果要加载特定资源,则必须将该资源放在 assets 下。

"assets": [
  "src/assets"
 ],

If you want to create new folder, then provide that folder path under assets in angular.json .如果要创建新文件夹,请在angular.json中的angular.json下提供该文件夹路径。

And provide relative path starting with your folder.并提供从您的文件夹开始的相对路径。 For example,例如,

Your image is under the path src/assets/images/1.jpg

Then you need to provide path as然后你需要提供路径作为

<img src="assets/images/1.jpg">

e2e folder is not a public folder. e2e 文件夹不是公用文件夹。 It will be used by e2e testing.它将被 e2e 测试使用。 You can google it by End to end testing (E2E).您可以通过端到端测试 (E2E) 进行谷歌搜索。 https://coryrylan.com/blog/introduction-to-e2e-testing-with-the-angular-cli-and-protractor https://coryrylan.com/blog/introduction-to-e2e-testing-with-the-angular-cli-and-protractor

您必须添加一个名为assets的目录,在此目录中您可以存储项目中所需的所有图像,要使用这些图像,您必须在图像标签的src属性中提供图像的相对路径

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

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