[英]@Url.Content isn't found in my javascript file
I have the next line in my javascript file: 我的javascript文件中有下一行:
"<img alt=\"Active\" src=\"@Url.Content(\"~/Images/play.png\")\" />"
so I tried to do what AHM
suggested in this topic ( @Url.Content in separate javascript file using ASPNET MVC 3 and Razor ): 因此,我尝试执行本主题中AHM
建议的操作( 使用ASPNET MVC 3和Razor在单独的javascript文件中@ Url.Content ):
var ROOT = "@Url.Content(\"~/";
"<img alt=\"Active\" src=\"" + ROOT + "Images/play.png\")\" />"
but I got an error: 但我得到一个错误:
Reports/@Url.Content( 404 (Not Found)
what I did wrong? 我做错了什么?
any help appreciated! 任何帮助表示赞赏!
@Url.Content
is not supported in JavaScript file JavaScript文件不支持@Url.Content
In your code is wrong 在你的代码是错误的
var ROOT = "@Url.Content(\"~/"; <= parentheses is not closed & you donot need to escape quotes
Instead use in beginning of file 而是在文件开头使用
var ROOT = '@Url.Content("~/")';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.