保存时 Visual Studio 代码格式化失败 [英] Visual Studio Code Formatting fail on save

查看:77
本文介绍了保存时 Visual Studio 代码格式化失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习 React Native.

I've started learning React Native.

我使用 Visual Studio Code 作为我的编辑器.

I'm using Visual Studio Code as my editor.

我已经设置了样板并启动了应用程序.但是,每当我更改 .js 文件并点击保存时,VSCode 都会搞乱所有格式.

I've set up the boiler plate and started the app. But whenever I change a .js file and hit save, VSCode is messing up all the formatting.

我以为我可以在 settings.json 文件中对其进行排序,但在谷歌搜索了一段时间后,我找不到正确的设置.

I thought I could sort this in the settings.json file but after googling for a while and playing around I can't find the correct setting.

这是一个错误还是我做错了什么?

Is this a bug or am I doing something wrong?

设置文件为默认文件:

更新:我重新安装了 vscode.然后设置一个带有 react native 标签和 html 标签的基本 js 文件.我添加了:

UPDATE: I re-installed vscode. Then set up a basic js file with a react native tag and a html tag. I added in:

"editor.formatOnSave": false,
"javascript.format.enable": false

到我的settings.json文件还是出现问题:

To my settings.json file and the problem still occurs:

问题是js文件中有标签,我只是不知道如何告诉vscode忽略它们?

The problem is having tags in a js file, I just don't know how to tell vscode to ignore them?

推荐答案

我通过查看扩展发现了这是什么.感谢@wgj 的提示.

I found out what this was by looking though the extensions. Thanks to @wgj for the hint.

原来是 JS-CSS-HTML 格式化程序.我查看了说明并暂时删除了自动保存.我必须为此制定具体的设置.

Turns out it was the JS-CSS-HTML formatter. I looked through the instructions and have removed the auto save for now. I'll have to work out the specific settings for this.

它使用 js-beautify,所以如果有人知道我应该查看的设置将不胜感激.

It uses js-beautify so if anyone knows the settings I should be looking at would be much appreciated.

这篇关于保存时 Visual Studio 代码格式化失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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