问题描述
在安装并启用了ESlint和Prettier的Nuxt应用程序中,我切换到了Visual Studio Code.
In my Nuxt application where ESlint and Prettier are installed and enabled, I switched to Visual Studio Code.
当我打开 .vue 文件并按 + + 并选择格式化文档,我的文件根本没有得到格式化
When I open a .vue file and press + + and choose Format Document, my file does not get formatted at all.
我的 .prettierrc 设置:
{
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
我的源代码行太多,因此无法手动设置它们的格式.我在做什么错了?
I have so many source code lines, so I cannot format them manually. What am I doing wrong?
推荐答案
在对Prettier停止在VSCode中工作感到非常沮丧之后,我如何对其进行排序.
How I've sorted it after having super huge frustrations with Prettier stopping working in VSCode.
- 选择
VS Code
->View
->命令面板
,然后键入:使用
- 然后
配置默认格式化程序...
,然后选择Prettier-代码格式化程序
.
- Select
VS Code
->View
->Command Palette
, and type:Format Document With
- Then
Configure Default Formatter...
and then choosePrettier - Code formatter
.
这神奇地为我解决了这个问题.
This sorted the problem for me magically.
根据您的情况,这可能会帮助您...
Depending on your case this might help you...
这篇关于为什么Prettier不在VS Code中格式化代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!