在VSCode扩展中贡献“array”类型的配置

问题描述 投票:8回答:1

我正在创建VSCode的扩展,需要配置包含字段的对象数组:a和b。使用扩展文档docs()中提供的信息,我不清楚,如果我可以定义数组元素的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个回答
7
投票

使用这样的示例配置

"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"
        }
    }
}

它会导致这个

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.