お世話になってます。
今、reactを使いたいのでHellow worldをテストしてます。
しかし、何も表示されずに困っています。
宜しければ、ご教示頂けないでしょうか?
宜しくお願いいたします。
希望表示: Hello div_nitta World
test.js
express = require('express') ,app = express() ,browserify = require('browserify') ,reactify = require('reactify') ,fs = require('fs'); app.get('/', function(req, res){ //ファイルを読み込んだら、コールバック関数を実行する。 fs.readFile('./my_index.html', 'utf-8' , doReard ); // コンテンツを表示する。 function doReard(err, data) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(data); res.end(); } }) app.get('/bundle.js', function(req, res){ res.setHeader('Content-type', 'text/javascript'); browserify('./app') .transform({ harmony: true }, reactify) .bundle() .pipe(res); }) app.listen(8124);
my_index.html
<html> <head> <title>React on NW.js</title> </head> <body> <div id="app"></div> <script src="/bundle.js"></script> </body> </html>
app.js
var Hello = React.createClass({ render: function() { return ( <h1>Hello, {this.props.name} World !</h1> ); } }); React.render( <Hello name='div_nitta' />, document.getElementById('app') );

回答1件
あなたの回答
tips
プレビュー