这个问题在这里已经有了答案:
9年前关闭。
Possible Duplicate:
Escape @ character in razor view engine
我如何在 MVC 页面( Razor 引擎)的脚本代码中使用“@”符号
写一个这样的代码:
<script>
var a = "this is a test text with @ symbol";
alert(a);
</script>
最佳答案
您可以使用两个 ampersat 符号进行转义: @@
。
var a = "this is a test text with @@ symbol";
顺便说一句,尽管我最近了解到并认为遇到这个问题的人也可能会发现它很有用:您可以使用 ampersat 符号和星号的组合进行评论:
@*this would comment out some code, or just allow for comments in general*@
关于asp.net-mvc-3 - 在 MVC 的脚本代码中使用 @,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9995871/