【问题标题】:I would like to format my html code in VS Code我想在 VS Code 中格式化我的 html 代码
【发布时间】:2020-08-18 23:36:58
【问题描述】:

我的 html 代码在我的角度组件中,我自动拥有:

     <a
        class="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-no-wrap uppercase text-white"
        href="#pablo"
      >
        pink Color
      </a>
      <button
        class="cursor-pointer text-xl leading-none px-3 py-1 border border-solid border-transparent rounded bg-transparent block lg:hidden outline-none focus:outline-none"
        type="button"
      >
        <span class="block relative w-6 h-px rounded-sm bg-white"></span>
        <span
          class="block relative w-6 h-px rounded-sm bg-white mt-1"
        ></span>
        <span
          class="block relative w-6 h-px rounded-sm bg-white mt-1"
        ></span>
      </button>

虽然我愿意:

      <a class="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-no-wrap uppercase text-white" href="#pablo">
        pink Color
      </a>
      <button class="cursor-pointer text-xl leading-none px-3 py-1 border border-solid border-transparent rounded bg-transparent block lg:hidden outline-none focus:outline-none" type="button">
        <span class="block relative w-6 h-px rounded-sm bg-white"></span>
        <span class="block relative w-6 h-px rounded-sm bg-white mt-1"></span>
        <span class="block relative w-6 h-px rounded-sm bg-white mt-1"></span>
      </button>

我在我的 settings.json 上进行搜索,但我不知道在哪里无法更改...有什么建议吗?

【问题讨论】:

标签: html css angular visual-studio-code tailwind-css


【解决方案1】:

我找到了解决方案!在 settings.json 中添加这一行

"[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
}

【讨论】:

    【解决方案2】:

    要获得更好的最新模式,请进入您的扩展选项卡并下载 Prettier 和 ESLint。

    因此,您可以在设置中添加:

    "[javascript, angular, html, css, json]": {
            "editor.formatOnSave": true
        },
        "eslint.quiet": true,
        "editor.codeActionsOnSave": {
            "eslint.autoFixOnSave": true,
        },
    

    或者编辑任何你想要的 vscode 语言。

    这将使代码始终尽可能地可读,而不管代码行的长度如何。

    【讨论】:

    • 它不起作用,我的代码总是以这种方式格式化:/谢谢你
    猜你喜欢
    • 1970-01-01
    • 2021-07-10
    • 1970-01-01
    • 2017-01-22
    • 2019-03-06
    • 2020-02-27
    • 2020-01-14
    • 2016-10-11
    • 1970-01-01
    相关资源
    最近更新 更多