对于javascript
条评论,我通常会尝试遵循与these条款类似的内容。但是,当它在cshtml
文件中看到类似的内容时,Razor引擎似乎就会出现:
/**
* This is my function.
* @param parm1 this is first parameter
* @param parm2 this is second parameter
*/
@符号似乎会导致解析器错误,因为这是Razor中的一个特殊字符。无论如何,我只是想知道其他人在做什么。我知道我可能会使用Razor评论并做这样的事情:
@*param parm1 this is first parameter *@
但是在很多层面上都感觉不对。
答案 0 :(得分:3)
试试这个:
/*
* This is my function.
* @@param parm1 this is first parameter
* @@param parm2 this is second parameter
*/
要写@
,您只需在Razor视图中重复@@
。
答案 1 :(得分:0)
Javascript样式/ * comment * /的注释位于脚本部分下。即<脚本> / * comment * /< / script>,评论样式/ *评论* /在剃刀下无效。 在HTML代码中,您可以使用< ! - 评论 - >,在Razor代码下你可以使用@ * comment * @
这是一个例子: ....剃刀文件 ..... 其他 { 没有结果。 }
@* razor comment *@
<!-- html comment -->
<p>
@if (ViewData["parent"] != null && !HasRole(Site.Enti))
{
// another type of comment with Razor
if (theParent.Parent == null)
{
@Html.ActionLink("Up One Level", "index", "")
}
else
{
@* another valid razor comment *@
@Html.ActionLink(
"Up One Level",
"index",
new { controller = "", id = theParent.Parent.SchoolGroupId })
}
}
<script>
/*
javascript comment
*/
</script>
........ 希望这个帮助