我刚刚开始研究React.js。我正在学习一些教程并测试一些示例。但是,当我找到一个道具的例子时,它并没有运行。我无法理解这个问题。以下是我的CMD的输出:
webpack: bundle is now INVALID.
Hash: b3302b07f8d42d8d5049
Version: webpack 1.13.1
Time: 297ms
chunk {0} index.js (main) 906 kB
[76] ./main.js 582 bytes {0} [built]
+ 247 hidden modules
webpack: bundle is now VALID.
这是Props.jsx:
import React from 'react';
class App extends React.Component {
render() {
return (
<div>
<h1>{this.props.headerProp}</h1>
<h2>{this.props.contentProp}</h2>
</div>
);
}
}
App.defaultProps = {
headerProp: "Header from props...",
contentProp: contentProp = "Content from props..."
}
export default App;
这是main.js:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './Props.jsx';
ReactDOM.render(<App />, document.getElementById('app'));
export default App;