Hier ist meine einfache reactjs Anwendung. Alles funktioniert gut, aber ich würde gerne wissen, wie separate Module zu erstellen, dh ich möchte die Komponenten in script.js trennen und fügen Sie eine andere Datei und fügen Sie es ein.reactjs - separate Module erstellen
Wie kann ich es in reactjs tun?
Derzeit ist die Anwendung nicht auf einem Server bereitgestellt.
script.js:
var CreatePanel = React.createClass({
render: function(){
return <div className="row">
<div className = "col-xs-6 col-sm-3">
<input type="text"></input>
<select></select>
</div>
</div>;
}
});
var FilterPanel = React.createClass({
render: function(){
return <div className="row">Filter Panel</div>;
}
});
React.render(<div class="container">
<CreatePanel/>
<FilterPanel/>
</div>
, document.getElementById('react-container'));
html
<!DOCTYPE html>
<html>
<head>
<script src="fb.me/react-0.13.3.min.js"></script>
<script src="cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.29/browser.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<title>React Components</title>
</head>
<body>
<div id="react-container"></div>
<script type="text/babel" src="./myscript.js">
</script>
</body>
</html>
Wie webpack oder browserify? – Scott