双程网络剧,女子机场行骗被抓,步步高音乐手机主题
mvc3.0中新增加了razor视图,razor视图的语法以@符号为核心,貌似在这个时代离不开@了,微博,邮箱都用这个。
1.输出变量和文本
[html]
@datetime.now
@datetime.now[html] view plaincopyprint?@for (int i = 0; i < 5; i++)
{
<p>@i</p>
}
@for (int i = 0; i < 5; i++)
{
<p>@i</p>
}
2.html标签编码
默认情况下是对html标签编码的。
使用html.raw对html标签不进行编码
[html]
@{
string str = "hello <br/>word";
@str
@html.raw(str)
}
@{
string str = "hello <br/>word";
@str
@html.raw(str)
}
3.注释
使用@* 注释内容 *@符号进行注释
[html]
@*
//返回方法返回值
*@
@*
//返回方法返回值
*@
4.单行输出
使用@:进行单行输出, 也可以使用 text标记进行单行输出
[html]
@{
@: hello
@: world
}
<text>
hello
world
</text>
@{
@: hello
@: world
}
<text>
hello
world
</text>
5.@前无空格输出变量
如果@前无空格输出变量,可以使用@()进行输出
[html]
<p>hello@(datetime.now)</p>
<p>hello@(datetime.now)</p>
6.在页面中输出@符号
如果想在页面中输出@符号,可用两个@符号来代替
[html]
<p>hello@@@(datetime.now)</p>
<p>hello@@@(datetime.now)</p>
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论