【问题标题】:Image not shown in C# code with a href code图像未显示在带有 href 代码的 C# 代码中
【发布时间】:2020-01-17 01:13:11
【问题描述】:

我只想显示存储在后端的图像。但是没有显示图像。我收到此错误:

downloadIcon.jpg:1 GET http://localhost:4200/assets/hepchat/images/downloadIcon.jpg 404 (Not Found)

我是这样做的:

 return $"<a href = \"{baseUrl}api/Devices/GetDownload/{model.AttachmentKey}/\" class=\"msgdownload\"><img src='./images/downloadIcon.jpg' alt=\"Download\"/></a>";

我有一个这样的 css 类:

.msgdownload {
  position: relative;
  width: 50px;
  height: 25px;
  display: block;

}

.msgdownload::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
}

而且我不想在 css 类中做这样的事情:

background: url(../hepchat/images/download.jpg) no-repeat bottom;

因为那时我不能有替代文本,当找不到图像时。

谢谢。

【问题讨论】:

  • 我做错了什么?谢谢你。我只有图像文件夹中的图像
  • 有什么建议吗?谢谢
  • 您将图像 URL 存储在哪里?你能告诉我你是如何将图像存储到你的文件夹中的吗?

标签: c# html css image


【解决方案1】:

您可以通过将图像放入/src/assets 文件夹来解决它。
比如:

/src/assets/hepchat/images/downloadIcon.jpg

【讨论】:

  • 谢谢。但我不希望它包含在 css 中
猜你喜欢
  • 2021-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多