这是我的jsx:
var React = require('react');
var ReactDOM = require('react-dom');
ReactDOM.render(
<h1>hello world</h1>,
document.getElementById('content')
)
我用 webpack 构建build/bundle.js
并
导入bundle.js
到index.html
索引.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
我该如何解决?(-_-)ゞ゛