我一直在尝试在我的一个应用程序中使用反应路由器。但我越来越
Uncaught TypeError: Cannot read property 'createClass' of undefined
在线的
var DefaultRoute = React.createClass({ ..
我一直在写的代码是
var Q = require('q'),
doThis = require('./generic/modules/doThis.js'),
doThat = require('./generic/modules/doThat.js');
var React = require('react');
var Router = require('react-router');
var Route = Router.Route;
var Redirect = Router.Redirect;
var DefaultRoute = Router.DefaultRoute;
var aModule = require('./modules/aModule/aModule.js');
var Master = require('./modules/master/master.js');
var injectTapEventPlugin = require('react-tap-event-plugin');
(function (){
var routes = (
<Route name="root" path="/" handler={Master}>
<Route name="time" handler={aModule} />
</Route>);
window.React = React;
injectTapEventPlugin();
var doThisPromise = doThis.init();
doThisPromise.
then(function() {
doThat.init();
Router.run (routes, function(Handler) {
console.log('in router run');
React.render(<Handler/>, document.body);
});
}, function (err) {
});
})();
如有需要请询问,我也会提供路线相关的js
-- 编辑 -- 构建文件中的相关错误代码
},{}],84:[function(require,module,exports){
var React = (window.React);
var FakeNode = require('../mixins/FakeNode');
var PropTypes = require('../utils/PropTypes');
/**
* A <DefaultRoute> component is a special kind of <Route> that
* renders when its parent matches but none of its siblings do.
* Only one such route may be used at any given level in the
* route hierarchy.
*/
var DefaultRoute = React.createClass({
displayName: 'DefaultRoute',
mixins: [ FakeNode ],
propTypes: {
name: React.PropTypes.string,
path: PropTypes.falsy,
handler: React.PropTypes.func.isRequired
}
});
module.exports = DefaultRoute;