首页 > 解决方案 > 如何配置 svelte 格式化程序以尊重 HTML 中的换行符?

问题描述

我有以下苗条的文件:

<script>
  import { text } from 'svelte/internal';
</script>

<style lang="scss">
  form {
    label, input {
      font-weight: 800;
    }
  }
</style>

<form>
  <label for="list">List</label>
  <input type="text" id="list" />
  <label for="password">Password</label>
  <input type="password" id="password" />
</form>

当我在这个文件上使用 shift + alt + f 这是我的输出:

<script>
  import { text } from 'svelte/internal';
</script>

<style lang="scss">
  form {
    label,
    input {
      font-weight: 800;
    }
  }
</style>

<form><label for="list">List</label> <input type="text" id="list" /> <label for="password">Password</label> <input type="password" id="password" /></form>

所以现在我的标签,CSS 中的输入在不同的行中,而我的 HTML 都在一行中。这与我想要的完全相反。

如何设置 vscode 以正确格式化此文件?

标签: visual-studio-codesvelte-3

解决方案


推荐阅读