我正在尝试通过 require 将 react 和 react-router 加载到我的应用程序中。我必须遵循 shim 设置,但在 react-router 没有获得正确的 React 对象时仍然出现错误。
paths: {
domReady: '../lib/requirejs-domready/domReady',
react: '../lib/react/react',
'react-router': '../lib/react-router/dist/react-router'
},
shim: {
'react': {
exports: 'React'
},
'react-router': {
deps: ['react'],
exports: 'ReactRouter'
}
}
require(['domReady!', 'react', 'react-router'], ...
Uncaught TypeError: Cannot read property 'createClass' of undefined react-router.js:372
../utils/withoutProperties react-router.js:1
s react-router.js:1
(anonymous function) react-router.js:62
./Route react-router.js:1
s react-router.js:1
(anonymous function) react-router.js:886
./actions/LocationActions react-router.js:1
s react-router.js:1
e react-router.js:1
(anonymous function) require.js:1658
context.execCb require.js:874
Module.check require.js:1151
Module.enable require.js:782
Module.init require.js:1178
callGetModule require.js:1552
context.completeLoad require.js:1679
context.onScriptLoad
一切都通过 Bower 安装。React 是 0.11.1,路由器是 0.7.0