小编use*_*023的帖子

如何在 VS Code 中使用 Prettier 在 vue 中强制每个属性换行?

我目前在 VSCode 中使用Prettier 版本:9.5.0 for Vue。

这是我当前的代码

<q-select label="Fruits" :options="['apple', 'mango']" />
Run Code Online (Sandbox Code Playgroud)

这就是我希望 Prettier 在保存时自动将其格式化的内容

<q-select 
label="Fruits" 
:options="['apple', 'mango']"
/>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已尝试根据这些发行说明singleAttributePerLine在 VSCode 中使用我的文件中的选项。但是它不起作用,VSCode 无法识别此配置。我也无法在 Prettier 扩展的设置菜单中找到此设置。我也尝试将此选项放入文件中但没有结果settings.json.editorconfig

我的settings.json文件配置

"editor.codeActionsOnSave": ["source.fixAll.eslint"],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.singleAttributePerLine":true,
Run Code Online (Sandbox Code Playgroud)

eslint vue.js visual-studio-code prettier

7
推荐指数
3
解决办法
5648
查看次数

标签 统计

eslint ×1

prettier ×1

visual-studio-code ×1

vue.js ×1