各位,问个问题,react直接在页面中引入的话,一个文件里面的多个components如何单独的分离成各个小的componen组件呢,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="./bower_components/react/react.min.js" charset="utf-8"></script>
<script src="./bower_components/react/react-dom.min.js" charset="utf-8"></script>
<script src="./bower_components/babel/browser.min.js" charset="utf-8"></script>
<script src="./components/scheduleComponent.js" type="text/babel" charset="utf-8"></script>
<script src="./index.js" type="text/babel" charset="utf-8"></script>
</head>
<body>
<div id="root" class="container"></div>
</body>
</html>
scheduleComponent.js
var ScheduleComponent = React.createClass({
render () {
return (
<div>Hello</div>
)
}
})
index.js
function Hello(props) {
return (
<div className="col-md-4">
<ScheduleComponent/>
</div>
)
}
ReactDOM.render(
<Hello/>, document.getElementById('root'))
新手表示为何不能这样做,在线等各位好心人求解
在scheduleComponent.js末尾添加:
然后在index.js首部添加: