Visual Studio 2022在“如果”中遇到HTML标签的问题剃须刀(CHTML)页面上的块
当在嵌套在DIV标签中的IF-Block中添加类似DIV标签时,Visual Studio将无法完成截止DIV标签。更糟糕的是,当我键入“ </div>
”时,它将在其前面创建另一个< div>
“在它的前面。
问题似乎是它在IF块之前没有检测到开放式DIV标签,并认为IF-Block之后的闭合标签是该内部div。但是,选择标签突出显示相应的开始或结束标签。
这是一个例子。
<div>
@if (condition)
{
<div>
THE FOLLOWING CLOSING TAG IS WHAT WILL NOT APPEAR.
</div>
}
</div>
我该如何解决?
When adding something like a div tag inside an if-block nested in div tag, Visual Studio will not finish the closing div tag. Worse yet, when I type "</div>
" it will create another "<div>
" in front of it.
The problem appears to be that it does not detect the opening div tag before the if-block and thinks the closing tag after the if-block is for that inner div. However, selecting the tags highlight the corresponding beginning or end tag.
Here is an example.
<div>
@if (condition)
{
<div>
THE FOLLOWING CLOSING TAG IS WHAT WILL NOT APPEAR.
</div>
}
</div>
How do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现的一个快速解决方法是首先键入左右角
&lt;&gt;
,该自动生成相应的&lt;/&gt;
。然后,只需左箭头添加到
&lt;&gt;
中,然后输入div
或span
等 - 无论您需要什么。似乎也可以在多个层次上工作。
A quick workaround I found is to first type the left-right angles
<>
, which automatically generates the corresponding</>
.Then, simply left-arrow into the
<>
, and type indiv
, orspan
etc - whatever you need.Seems to work at multiple levels of nesting as well.