Uncaught ReferenceError: exports is not defined using reactjs
Uncaught ReferenceError: exports is not defined using reactjs
我正在 第一次 尝试 react.js,我下载了示例项目 from here
并创建了一个 scripts.js like 所以:
import React from 'react';
class App extends React.Component {
constructor () {
super ();
this.state = {
text: 'Default text'
}
}
update (e) {
this.setState ({text: e.target.value});
}
render () {
return (
<div>
<input onChange={this.update.bind(this)} type="text" />
<div>{this.state.text}</div>
</div>
)
}
}
export default App;
但是会引发此错误
知道我做错了什么吗?
顺便说一句,这就是 .html 的样子(截图是因为它使用了 url-shorteners)
对此我不是 100% 确定,但看起来您在不支持这些功能的环境中使用 ECMA6/7 功能。
要快速轻松地设置支持 ECMA6/7 的项目,您可以使用 create-react-app package
我正在 第一次 尝试 react.js,我下载了示例项目 from here
并创建了一个 scripts.js like 所以:
import React from 'react';
class App extends React.Component {
constructor () {
super ();
this.state = {
text: 'Default text'
}
}
update (e) {
this.setState ({text: e.target.value});
}
render () {
return (
<div>
<input onChange={this.update.bind(this)} type="text" />
<div>{this.state.text}</div>
</div>
)
}
}
export default App;
但是会引发此错误
知道我做错了什么吗?
顺便说一句,这就是 .html 的样子(截图是因为它使用了 url-shorteners)
对此我不是 100% 确定,但看起来您在不支持这些功能的环境中使用 ECMA6/7 功能。
要快速轻松地设置支持 ECMA6/7 的项目,您可以使用 create-react-app package