我正在使用react(0.14.2)博客中的示例:
var React = require('react');
var ReactDOM = require('react-dom');
var MyComponent = React.createClass({
render: function() {
return <div>Hello World</div>;
}
});
console.info('reactdom render');
ReactDOM.render(<MyComponent />, document.getElementById('whoopidoo'));
我用grunt编译它:
browserify: {
options: {
transform: [
['babelify', {
loose: 'all'
}]
]
},
将脚本包含在html页面中:
<script src="1_basic_minimal.js" type="text/javascript"></script>
但页面只是空白,没有错误,绝对没有。我的编译错了吗?
修改 文件内容:
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({},{},[]);