Razor 不理解未关闭的 html 标签 [英] Razor doesn't understand unclosed html tags
本文介绍了Razor 不理解未关闭的 html 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 RazorViewEngine,我可以做到:
if (somecondition) {<div>一些东西
}
但我似乎无法做到这一点(Razor 感到困惑):
if (somecondition) {<div>}如果(其他条件){
}
我遇到了一种情况,需要将打开和关闭 html 标记放在不同的代码块中 - 我如何在 Razor 中执行此操作?
解决方案
试试这个:
if (somecondition) {@:}With RazorViewEngine, I can do this:
if (somecondition) {
<div> some stuff </div>
}
but I can't seem to do this (Razor gets confused):
if (somecondition) {
<div>
}
if (someothercondition) {
</div>
}
I have a situation in which I need to put my opening and closing html tags in different code blocks - how can I do this in Razor?
解决方案 Try like this:
if (somecondition) {
@:<div>
}
这篇关于Razor 不理解未关闭的 html 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文