简体   繁体   English

使用 VsCode 更漂亮

[英]Prettier with VsCode

I'm trying to integrate Prettier in Visual Studio Code.我正在尝试将 Prettier 集成到 Visual Studio Code 中。

I've installed the Prettier VsCode plugin .我已经安装了Prettier VsCode 插件

In the instructions it says to set the following VSCode setting:在说明中说要设置以下 VSCode 设置:

"editor.defaultFormatter": "esbenp.prettier-vscode",

However, when I do this Visual Studio gives the message: "Unknown configuration setting".但是,当我这样做时,Visual Studio 会给出消息:“未知配置设置”。

And whenever I try to format the Javascript files it does not use prettier.每当我尝试格式化 Javascript 文件时,它都不会使用更漂亮的文件。 I've uninstalled all other extensions just to be sure that nothing was interfering with the prettier extension.我已经卸载了所有其他扩展,只是为了确保没有任何东西干扰更漂亮的扩展。

Prettier does work correctly if I execute it with the command line:如果我使用命令行执行 Prettier 确实可以正常工作:

npx prettier --write .

Does anyone know how this can be resolved?有谁知道如何解决这个问题?

I've found the problem.我发现了问题。

Turns out I was using an old version of Visual Studio Code (1.22.0)原来我使用的是旧版本的 Visual Studio Code (1.22.0)

The "Check for updates" button gave the message that there were no updates available, so I figured that I was on the latest version already. “检查更新”按钮显示没有可用更新的消息,所以我认为我已经使用了最新版本。 But, this was not the case.但是,事实并非如此。

After downloading the new version everything works as expected.下载新版本后,一切都按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM