首页 > 解决方案 > 如何让 React .js 文件正确格式化

问题描述

我有一个App.js在 Visual Studio Code 中命名的文件,该文件实际上在浏览器中呈现良好,但格式不正确:

在此处输入图像描述

我已将文件类型切换为javascriptreact

在此处输入图像描述

但它仍然不会用SHIFT-ALT-F.

这是我的settings.json文件:

{
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "explorer.confirmDelete": false,
    "files.autoSave": "afterDelay",
    "editor.formatOnSave": true,
    "explorer.confirmDragAndDrop": false,
    "editor.acceptSuggestionOnEnter": "off",
    "editor.fontSize": 12,
    "window.zoomLevel": 0,
    "workbench.editor.enablePreview": false,
    "editor.renderWhitespace": "all",
    "[javascriptreact]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "[javascript]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "[html]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "[json]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "editor.wordWrap": "on",
    "git.enableSmartCommit": true,
    "git.autofetch": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "workbench.sideBar.location": "left",
}

我还需要设置什么才能SHIFT-ALT-F正确格式化我的 React Javascript 文件?

标签: javascriptreactjsvisual-studio-code

解决方案


推荐阅读