【问题标题】:Contributing configuration of type "array" in VSCode extension在 VSCode 扩展中贡献类型“数组”的配置
【发布时间】:2016-07-30 20:39:25
【问题描述】:

我正在创建 VSCode 扩展,需要使用包含字段的对象数组进行配置:a 和 b。使用扩展文档()中提供的信息,我不清楚是否可以定义数组元素的configuration 模式,是否将属性类型设置为"array"。我尝试将以下代码放在"configuration" 贡献中,但没有成功(我可以在代码中成功检索配置,但用户填写数据时没有IDE提示):

"title": "My config",
"properties": {
  "array_property": {
    "title": "Property",
    "type": "array",
    "properties": {
      "a": {
        "type": "string",
        "description": "A a"
      },
      "b": {
        "type": "string",
        "description": "A b"
      }
    }
  }
}

我尝试将"type": "array" 替换为"type": ["array", "object"],但没有任何改变。

【问题讨论】:

    标签: visual-studio-code vscode-extensions


    【解决方案1】:

    使用这样的示例配置

    "configuration": {
        "type": "object",
        "title": "Test configuration",
        "properties": {
            "mytest.objarrconf": {
                "type": "array",
                "items": {
                    "type": "object",
                    "title": "inner objects",
                    "properties": {
                        "name": {
                            "type": "string",
                            "description": "Name of inner object"
                        },
                        "size": {
                            "type": "number",
                            "description": "Size of inner object"
                        }
                    }
                },
                "default": [],
                "description": "my test configurations"
            }
        }
    }
    

    它会导致这个

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    相关资源
    最近更新 更多