当我的具有属性的元素变长时,VS Code 似乎将行分成多行:
(我想要三行而不是七行,每个元素一行)
我使用 prettier 进行格式化,并设置了printWidth在 javascript 代码中工作的选项,但对于 HTML,它似乎被 VS Code 覆盖。
我试过摆弄wrapAttributes和html.format.wrapLineLength设置,但这些似乎都没有任何效果。
如何处理这件事?
更新:
非常感谢你的回答。我还没有收到他们的通知,很抱歉没有采取行动。
我已经尝试了您的所有建议,但问题仍然存在。这是我根据您的建议当前的配置。
设置.json:
"html.format.wrapLineLength": 0,
"html.format.enable": false,
"html.format.wrapAttributes": "auto",  
"vetur.format.defaultFormatterOptions": {
    "prettyhtml": {
        "printWidth": 300,
        "singleQuote": false,
        "wrapAttributes": false,
        "sortAttributes": false
    }
}
.prettierrc.json:
{
  "semi": true,
  "trailingComma": "none",
  "singleQuote": true,
  "printWidth": 300,
    "tabWidth": 2,
    "useTabs": true,
    "jsxBracketSameLine": true
}
我需要这个:
    var short_sleeve = {
        type: "Short Sleeve",
        id: this.item.epos_code,
    };
看起来像这样:
var short_sleeve = { type: "Short Sleeve", id: this.item.epos_code, };
这是我的 prettierrc.json:
{
    "bracketSpacing": false,
    "endOfLine": "auto",
    "printWidth": 300,
    "proseWrap": "never",
    "tabWidth": 4,
    "trailingComma": "all",
    "useTabs": true
}
这是我的 vs code settings.json
{
    "prettier.singleQuote": true,
    "prettier.tabWidth": 4,
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "prettier.printWidth": 300,
    "editor.formatOnSave": true,
    "files.trimTrailingWhitespace": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "prettier.proseWrap": "never",
    "materialTheme.accent": "Acid Lime",
    "twig-language.wrap": 100
}
我已经尝试过这里的解决方案:Prevent Prettier from conversion single line object statements into multi line in …