为什么 Prettier 不在 VS Code 中格式化代码? [英] Why does Prettier not format code in VS Code?

查看:50
本文介绍了为什么 Prettier 不在 VS Code 中格式化代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装并启用了 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 文件并按 CMD+ Shift + P 并选择 格式化文档,我的文件根本没有格式化.

When I open a .vue file and press CMD+ Shift + P 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.

  1. 选择VS Code -> View -> Command Palette,然后输入:Format Document With
  2. 然后 Configure Default Formatter... 然后选择 Prettier - Code formatter.
  1. Select VS Code -> View -> Command Palette, and type: Format Document With
  2. Then Configure Default Formatter... and then choose Prettier - Code formatter.

这对我来说神奇地解决了问题.

This sorted the problem for me magically.

根据您的情况,这可能会对您有所帮助...

Depending on your case this might help you...

这篇关于为什么 Prettier 不在 VS Code 中格式化代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆