HTML 是否有 #Region 代码
在 VB 和 C# 中,有 #Region ... #endRegion
并使其可折叠。 HTML 中有类似的方法吗?
现在,我只是在 HTML 页面上的不同元素处添加了注释,但我希望有一个折叠点,而不是所有
;
和
标签已折叠。In VB and C# there are #Region ... #endRegion
and have it collapsable. Is there a similar way to do this in HTML?
Right now I just have comments blocking where the different elements are on my HTML page, but I would like to have a single collapse point instead of all of the <tr>
<td>
and <div>
tags collapsed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
在 Visual Studio Code 中,可以通过使用正确的语法来完成此操作:
确保
#
和region
或endregion
之间没有空格。In Visual Studio Code, this can be done by using the correct syntax:
Make sure there are no spaces between the
#
andregion
orendregion
.这确实取决于 IDE,今天刚刚注意到 Visual Studio 的免费 Web Essentials 2012 插件的最新版本添加了 HTML 区域支持。
http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6< /a>
http://vswebessentials.com/changelog
This indeed depends on the IDE, just noticed today that the newest version of the free Web Essentials 2012 plugin for Visual Studio has added region support in HTML.
http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6
http://vswebessentials.com/changelog
从 Visual Studio 2013 Update 4 开始,HTML 编辑器现在支持区域。您可以使用内置的代码片段:输入“
您可以在此处的更新 4 中找到此改进和其他新功能的详细信息。
As of Visual Studio 2013 Update 4 regions are now supported in the HTML editor. You may use the built in code snippet: type "
You can find the details of this improvement and other new features in update 4 here.
我认为简短的答案是否定的。
Region只是编辑器(Visual Studio)识别的IDE指令。 HTML 标准中没有任何内容,您在 HTML 中放入的任何内容也会直接发送到浏览器,因此我没有遇到任何内容,也无法想象会有任何内容。
I think the short answer is no.
Region is only a IDE directive recognised by the editor (Visual Studio). There is nothing in the HTML standard and anything you did put in the HTML would be sent straight down to the browser too, so I've not come across anything and can't imagine there would ever be anything.
突出显示要折叠的部分,然后转到
Edit ->概述->隐藏选择
参考:如何:在可视化 Web 中折叠和展开 HTML 元素开发人员
编辑:这假设您使用的是 Visual Studio
Highlight the section you want collapsed, then go to
Edit -> Outlining -> Hide Selection
Reference: How to: Collapse and Expand HTML Elements in Visual Web Developer
Edit: This assumes you're using Visual Studio
对于 Html:
对于 Javascript:
如您所见,Visual Studio 在注释内声明区域块。
Html 中的注释符号
//
Javascript 中的注释符号For Html:
For Javascript:
As you see, Visual Studio states region blocks inside of comments.
<!-- -->
sign of comment in Html//
sign of comment in Javascript为了使大纲在 Visual Studio 2019 中工作,请确保评论结束标记前后都有空格:
注意:这在
中不起作用Visual Studio 2022 尚未发布。
In order for outlining to work in visual studio 2019, make sure to have space before and after the comment closing tags:
Note: this won't work in
Visual Studio 2022
yet.我使用 div 标签来折叠 html 代码块:
在我学习
它们都解决问题之前。
I used div tag to collapse html code blocks :
before I learn
both of them solve problem.
您可以将其用于折叠注释,
因此 div 可以在 VS 中的 html 代码中折叠或展开
You can use this for your collapse comments
So div can collapse or expand in html code in VS
奇怪的是,有时区域功能在 Visual Studio 2022 中对我有用,有时却不起作用。我尝试了上面的许多方法,对于该区域是否真正创建还是没有把握。
但我发现这每次都有效:
它每次都会崩溃,并且清楚地显示区域名称。
**更新感谢@AndrewMorton 评论。
Strangely, sometimes the region feature works for me in Visual Studio 2022, and sometimes it does not. I tried many of the above, and it is hit or miss as to whether the region is actually created or not.
But I have found this to work every time:
It collapses every time, and it shows the region name plainly.
**Updated thanks to @AndrewMorton comment.