【问题标题】:Expected an identifier and instead saw '>'需要一个标识符,而是看到“>”
【发布时间】:2018-10-18 04:00:30
【问题描述】:
ReactDOM.render(<App />, document.getElementById('root'));

请告诉我为什么 VSCode [jshint] 会出现这个问题?另外请告诉我如何在.jshintrc中添加一些代码

【问题讨论】:

    标签: reactjs visual-studio-code jshint


    【解决方案1】:

    JSHint 不支持 jsx 的 linting。如果您想使用 jsx 开发 React 应用程序,您应该禁用它或更好地切换到 ESLint

    对于 Visual Studio Code,您可以安装 a plugin

    【讨论】:

      【解决方案2】:

      按⇧⌘X,然后写在那里jshint并卸载它。

      然后编写 eslint 并在之前安装它。

      并确保您的 "esversion":6 为 6,以便遵循以下流程

      对于 Mac VSCode:代码(左上角)=> 首选项 => 设置 => 用户设置。 并在右侧检查并写在下面的代码

      {
        "workbench.colorTheme": "Visual Studio Dark",
        "git.ignoreMissingGitWarning": true,
        "window.zoomLevel": 0,
        // you want to write below code for that
        "jshint.options": {
            "esversion":6
        },
      }
      

      【讨论】:

      • 如果你卸载 jshint 包,我认为“jshint.options”不会有任何影响。
      【解决方案3】:

      如果你已经在 VS 代码中安装了 jshint,并且在你的 react 应用中出现错误,那么你可以禁用 jshint 扩展,它将解决所有问题。

      【讨论】:

        猜你喜欢
        • 2019-05-07
        • 1970-01-01
        • 1970-01-01
        • 2018-09-07
        • 1970-01-01
        • 1970-01-01
        • 2014-11-27
        • 2023-03-11
        • 1970-01-01
        相关资源
        最近更新 更多