VS Code 的设置 html.format.unformatted 有什么作用?

And*_*sal 3 visual-studio-code vscode-settings

我试图弄清楚 VS Codehtml.format.unformatted设置的作用,但我不能。

我在 GitHub 中发现了这个问题这个问题,但它什么也没解释。

有人可以向我解释html.format.unformatted设置的作用以及它与html.format.contentUnformatted设置的不同之处吗?

Vet*_*ras 7

经过多次反复试验,我发现了这一点:

域名注册地址:

  • html.format.unformatted: 不格式化标签本身或内容
  • html.format.contentUnformatted: 将格式化标签而不是内容

来源(不太清楚,恕我直言):https : //code.visualstudio.com/Docs/languages/html


示例 html 代码(无效,我知道,但在这里无关紧要):

<body>

    <style class="foo"        class="foo"        class="foo"    >
            .foo {
            background-image: 'bar.jpeg';
            background-size: cover;
            background-position-x: 50%;
            background-position-y: 50%;
            }
    </style>

    <div class="foo">
        <div>
            <div></div>
            whatever
            <div></div>
        </div>
    </div>
</body>
Run Code Online (Sandbox Code Playgroud)

使用此配置:

{
    "html.format.wrapAttributes": "force-expand-multiline",
    //"html.format.contentUnformatted" : "style",
    "html.format.unformatted": "style"
}
Run Code Online (Sandbox Code Playgroud)

当我们在上面的示例 html 上触发自动格式时,STYLE TAG 没有格式化并且 style 标签内容没有改变。

使用此配置:

{
    "html.format.wrapAttributes": "force-expand-multiline",
    "html.format.contentUnformatted" : "style",
    //"html.format.unformatted": "style"
}
Run Code Online (Sandbox Code Playgroud)

当我们在上面的示例 html 上触发自动格式时,样式标记已格式化(空格、标识等),样式标记内容未更改。