gpt4 book ai didi

javascript - 无法在 MVC 4 中加载超链接的图像

转载 作者:行者123 更新时间:2023-11-28 20:14:21 26 4
gpt4 key购买 nike

我正在开发一个模块,其中按钮/超链接应在 MVC 4 View 中显示为图像而不是常规文本。我有以下代码片段。

<td>
<a href="#" data-bind="click: $root.edit"><img src="~/Images/edit.png" /></a>
<a href="#" data-bind="click: $root.remove"><img src="~/Images/del.png" /></a>

<a href="#" data-bind="click: $root.add"><img src="~/Images/add.png" /></a>

I have all the image files added in the solution in the Images folder, but for some reasons, they are not displaying in the UI. The error I am getting is

"GET http://localhost:20823/~/Images/del.png 404 (Not Found) " 
"GET http://localhost:20823/~/Images/edit.png 404 (Not Found) "

"GET http://localhost:20823/~/Images/add.png 404 (Not Found) "

最佳答案

您需要使用Url.Content将相对路径解析为绝对路径,例如

<img src='@Url.Content("~/Images.edit.png")' />

关于javascript - 无法在 MVC 4 中加载超链接的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19430756/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com