代码之家  ›  专栏  ›  技术社区  ›  KyleMit Steven Vachon

VS代码-使用JSON模式验证本地文件路径中的值

  •  0
  • KyleMit Steven Vachon  · 技术社区  · 6 年前

    在VS代码中,有几个标记触发本地文件路径引用的自动完成和验证。例如,输入img标记时:

    Path autocomplete

    图像.json

    [
        {
            "color": "red",
            "path": "./images/kitten.jpeg" /* identify value type as local path */
        },
        /* ... more items ...*/
    ]
    

    这是一个 JSON Schema Definition 一直以来 applied to the vs workplace settings

    .vscode代码/设置.json

    {
        "json.schemas": [
            {
                "fileMatch": [
                    "/images.json"
                ],
                "schema": {
                    "$schema": "http://json-schema.org/draft-07/schema#",
                    "type": "array",
                    "items": [
                      {
                        "type": "object",
                        "properties": {
                          "color": {"type": "string", "enum": ["blue", "red", "green"]},
                          "path":  {"type": "string", /* what to put here */},
                        }
                      },
                    ]
                  }
            }
        ]
    }
    

    有没有方法可以使用检查本地文件路径 JSON Schema Validation 或者用其他方法告诉VS代码某个字段代表本地文件引用?

    0 回复  |  直到 6 年前