VS Code 内置颜色选择器功能在 JSON 文件中不起作用 [英] VS Code built-in color picker feature doesn't work in JSON files

查看:21
本文介绍了VS Code 内置颜色选择器功能在 JSON 文件中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 VS Code 具有内置颜色选择器功能
但我不明白为什么它不适用于我的 JSON 文件.

I have found info that VS Code has built-in color picker feature
But I can't figure out why it doesn't work for my JSON files.

例如,这是我的 apple.json 文件:

For instance, this is my apple.json file:

{
    "apple": {
        "color": "#ff0000"
    }
}

所以,颜色选择器不会出现.

So, color picker doesn't appear.

但是 - 如果我打开 VS Code 自己的 settings.json 文件,并像这样更新它,例如:

But - if I open VS Code's own settings.json file, and update it like so, for instance:

{
"workbench.colorCustomizations": {
    "activityBar.background": "#00AA00"
  }
}

颜色选择器会立即出现.

color picker will instantly appear.

为什么?apple.json 和 settings.json 有什么不同?

Why? What differs apple.json from settings.json?

推荐答案

要完成这项工作,您需要一个与 json 文件关联的 JSON 模式.模式必须在表示颜色的属性上说 format: color.只有这样才会显示颜色装饰器和选择器.

To have that work, you need a JSON schema associated with the json file. The schema has to say format: color on the property that represents a color. Only then a color decorator and picker is shown.

如果您想设置自己的 JSON 架构,可以查看此处:https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings

You can look here if you want to set up your own JSON schema: https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings

这篇关于VS Code 内置颜色选择器功能在 JSON 文件中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆