Visual Studio 2022在“如果”中遇到HTML标签的问题剃须刀(CHTML)页面上的块

发布于 2025-02-03 13:16:51 字数 431 浏览 2 评论 0原文

当在嵌套在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们只是彼此的过ke 2025-02-10 13:16:51

我发现的一个快速解决方法是首先键入左右角&lt;&gt;,该自动生成相应的&lt;/&gt;

然后,只需左箭头添加到&lt;&gt;中,然后输入divspan等 - 无论您需要什么。

似乎也可以在多个层次上工作。

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 in div, or span etc - whatever you need.

Seems to work at multiple levels of nesting as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文