gpt4 book ai didi

asp.net-mvc-3 - Razor 不理解未封闭的 html 标签

转载 作者:行者123 更新时间:2023-12-01 23:10:57 24 4
gpt4 key购买 nike

使用 RazorViewEngine,我可以这样做:

if (somecondition) {
<div> some stuff </div>
}

但我似乎无法做到这一点(Razor 感到困惑):
if (somecondition) {
<div>
}

if (someothercondition) {
</div>
}

我有一种情况,我需要将我的开始和结束 html 标签放在不同的代码块中 - 我如何在 Razor 中做到这一点?

最佳答案

试试这样:

if (somecondition) {
@:<div>
}

关于asp.net-mvc-3 - Razor 不理解未封闭的 html 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4809694/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com