【问题标题】:How to do region collapse for JS in Visual Studio 2012/2013如何在 Visual Studio 2012/2013 中为 JS 做区域折叠
【发布时间】:2015-01-09 00:01:50
【问题描述】:

Visual Studio 2012 和 2013 中 JS 的区域代码崩溃?

#region AutoComplete JS
$("#<%=txtBirim.ClientID %>").autocomplete({
   source: function (request, response) {
     $.ajax({
       url: '<%=ResolveUrl("~/Classlar/TextboxOtomatik.asmx/BirimGetir") %>',
       data: "{ 'prefix': '" + request.term + "'}",
       dataType: "json",
       type: "POST",
       contentType: "application/json; charset=utf-8",
       success: function (data) {
       response($.map(data.d, function (item) {
         return {
         label: item.split('-')[0],
         val: item.split('-')[1]
       }
      }))
     },
    Code....
#endregion

有没有办法做这样的事情?

【问题讨论】:

    标签: javascript visual-studio-2012 visual-studio-2013 region


    【解决方案1】:

    安装网络必需品

    在结束区域使用相同的名称

    //#region AutoComplete JS
    $("#<%=txtBirim.ClientID %>").autocomplete({
          source: function(request, response) {
              $.ajax({
                    url: '<%=ResolveUrl("~/Classlar/TextboxOtomatik.asmx/BirimGetir") %>',
                    data: "{ 'prefix': '" + request.term + "'}",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    success: function(data) {
                      response($.map(data.d, function(item) {
                        return {
                          label: item.split('-')[0],
                          val: item.split('-')[1]
                        }
                      }))
                    },
                    Code....
    //#endregion AutoComplete JS
    

    【讨论】:

    • 您需要使用 WebEssentials...vswebessentials.com/features/javascript
    • @QMaster 安装 WebEssentials
    • 虽然@umair 解决方案有效,但我会检查是否安装了 WebEssentials,如果没有,我必须决定仅使用 js 区域安装它是否明智!
    • 已安装 WebEssentials,但不幸的是在 JS 代码的某些部分中不起作用,例如$(document).on("点击", ".....
    • 不幸的是,@umair 解决方案不是持久的 :(
    【解决方案2】:

    安装 Visual Studio Advanced Javascript Outlining 扩展后,它对我有用。

    你可以找到扩展名here

    安装扩展后,只需重启你的 Visual Studio,你就可以像这样使用它了

    //#region MyRegion
    
    Code Here
    
    //#endregion 
    

    【讨论】:

    • 按照 OP 的要求,发布的解决方案适用于 VS 版本 2012/13。
    • 到目前为止,高级 Javascript 大纲扩展无法与 VS 2017 一起使用。还有其他方法可以让 VS 2017 的区域崩溃吗?
    • 对于 2017-从这里下载扩展 marketplace.visualstudio.com/…
    【解决方案3】:
    1. 选择要隐藏的javascript代码 2.按(

    a.Ctrl+M

    然后

    b.Ctrl+H ) 然后你可以命名你的地区

    【讨论】:

    • 更多详情见本页blog.degree.no/2013/05/…
    • 我赞成这个答案,但我发现在关闭项目大纲 [created with ctrl+M -> ctrl+H] 后被删除:(
    【解决方案4】:

    如果您在 Visual Studio 中使用 Web Essentials,那么您将无法编写

    //#region AutoComplete JS
    youcode
    //#endregion
    

    看到这个link

    【讨论】:

      【解决方案5】:

      视觉工作室: 只需选择要折叠的代码区域,然后右键单击鼠标,单击大纲,然后单击隐藏选择。 您将在左侧垂直条上看到折叠 (+) 符号。 快捷键是Ctrl+M,选择后是Ctrl+H。

      【讨论】:

        猜你喜欢
        • 2013-01-24
        • 1970-01-01
        • 1970-01-01
        • 2017-08-08
        • 2014-01-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多