模块解析失败:意外的令牌(4:16)

时间:2020-08-30 02:20:15

标签: javascript reactjs webpack babeljs

我是前端开发的新手。我似乎收到此错误:

ERROR in ./js/index.jsx 4:16
Module parse failed: Unexpected token (4:16)
You may need an appropriate loader to handle this file type, currently, no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import ReactDOM from "react-dom";
| import App from "./App";

代码如下:

ReactDOM.render(<App />, document.getElementById("content"));

先谢谢您

1 个答案:

答案 0 :(得分:0)

正如大多数评论中的人已经指出的那样,您不能对该函数使用空的第一个参数,因为它不是可选的。这是您代码的外观:

ReactDOM.render(App, document.getElementById("content"));

编辑:<App />不是您在渲染函数中应用App组件的方式,只是像上面的示例一样使用App变量。