【发布时间】:2016-08-07 22:42:12
【问题描述】:
我是 React 的新手,所以也许专家会很快发现问题。这是我的router.js:
define(["backbone", "react", "jsx!view/todoList"], function(Backbone, React, ReactDOM, TodoList) {
return Backbone.Router.extend({
routes : {
"" : "index"
},
index : function() {
console.log("hello world");
var todos = new Backbone.Collection([
{
text: 'Dishes!',
dueDate: new Date()
}
]);
React.render(<TodoList todos={todos} />, document.body);
}
});
});
我在控制台中收到以下错误:VM7282:19 Uncaught TypeError: TodoList is not a function。
也许问题在于已弃用的 JSXTransformer (https://facebook.github.io/react/blog/2015/06/12/deprecating-jstransform-and-react-tools.html)。建议改用 Babel(在我的情况下,而不是 jsx!view/todoList 来使用 babel!view/todoList)。我遇到的问题是从哪里导入 babel.js。这里http://facebook.github.io/react/docs/displaying-data.html 他们导入https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js 但是当我做同样的事情时 babel!view/todoList 不起作用。
【问题讨论】:
标签: reactjs react-router jsx babeljs require