这是我的 JSX:
但是当我运行webpack-dev-server时,chrome控制台显示错误:
我确定我已经运行了
![enter image description here](https://istack.dev59.com/2aXMx.webp)
如何解决?(-_-)ゞ゛
var React = require('react');
var ReactDOM = require('react-dom');
ReactDOM.render(
<h1>hello world</h1>,
document.getElementById('content')
)
我使用webpack构建,生成build/bundle.js
文件,并将其导入到index.html
中。
index.html:
<!DOCTYPE html>
<html>
<head>
┊ <meta charset="utf-8">
┊ <meta name="viewport" content="width=device-width">
┊ <title></title>
</head>
<body>
┊ <div id="content"></div>
┊ <script src="./build/bundle.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
但是当我运行webpack-dev-server时,chrome控制台显示错误:
bundle.js:57 Uncaught ReferenceError: React is not defined
我确定我已经运行了
npm install react
![enter image description here](https://istack.dev59.com/2aXMx.webp)
如何解决?(-_-)ゞ゛
npm start
并在命令行上看到它的运行情况? - user4398985