如何防止在 JSX 代码中插入空格 [英] How to prevent insert spaces in JSX code

查看:33
本文介绍了如何防止在 JSX 代码中插入空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习 React Native.我正在使用 Visual Studio Code 进行编辑.每当我保存文件时,它都会在我的 JSX 代码中插入空格.这降低了代码的可读性.这是我保存文件之前的代码

I have just started learning React Native. I am using Visual Studio Code for editing. Whenever I save my file it is inserting spaces in my JSX code. This reduces the readability of the code. This is code before I save the file

保存文件前:

这是保存后的文件:

This is File after saving:

我尝试过编辑 VS Code 设置

I have tried editing VS Code settings

"javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false

但这没有帮助.

有什么办法可以解决这个问题吗?

Is there any solution to this problem?

推荐答案

我设法通过手动将文件的语言更改为 javascriptreact 而不是 javascript 来解决此问题.

I managed to resolve this by manually changing the language of the file to javascriptreact instead of javascript.

截图:

这篇关于如何防止在 JSX 代码中插入空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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