Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 关闭大括号时如何阻止vscode删除缩进_Reactjs_Visual Studio Code_Formatting_Indentation_Curly Braces - Fatal编程技术网

Reactjs 关闭大括号时如何阻止vscode删除缩进

Reactjs 关闭大括号时如何阻止vscode删除缩进,reactjs,visual-studio-code,formatting,indentation,curly-braces,Reactjs,Visual Studio Code,Formatting,Indentation,Curly Braces,希望你们能帮助我,当我合上花括号时,vscode正在移除缩进,这是对我的注释,这是一张发生了什么的gif 原因是您的VS代码不知道JS文件中的JSX。 尝试按以下方式更改用户设置或工作区设置: // Place your settings in this file to overwrite the default settings { "files.associations": { "*.js": "javascriptr

希望你们能帮助我,当我合上花括号时,vscode正在移除缩进,这是对我的注释,这是一张发生了什么的gif


原因是您的VS代码不知道JS文件中的JSX。 尝试按以下方式更改用户设置或工作区设置:

// Place your settings in this file to overwrite the default settings
{
    "files.associations": {
        "*.js": "javascriptreact"
    }
}

注意:您可能需要重新启动VSCode。

将设置(文本编辑器)中的自动缩进更改为保持完整。(见下面的屏幕截图)


注意:它可能会影响其他内容,但解决了问题。

尝试过,但仍然删除了缩进:c无论如何,谢谢!是的,你说得对。我找到了另一个解决办法。请检查下面。我使用的是prettier,也有同样的问题,但一旦我保存它,它的格式就会正确。它成功了!非常感谢你!