【发布时间】:2015-09-21 12:03:46
【问题描述】:
var CommentList = React.createClass({
render: function () {
return (
<div className="commentList">
Hello, world!I am a CommentList.
</div>
);
}
});
var CommentBox = React.createClass({
render: function () {
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList /> //ERROR
</div>
);
}
});
React.render(
React.createElement(CommentBox, null),
document.getElementById('content')
);
使用此代码,我收到以下错误消息: JSX 元素类型“CommentList”没有任何构造或调用签名。
相同的代码适用于纯 HTML/JS(按照本教程:https://facebook.github.io/react/docs/tutorial.html)
我不知道为什么 TypeScript 不喜欢它。 将 Visual Studio 2013 与 TS 1.6 (http://blogs.msdn.com/b/typescript/archive/2015/09/16/announcing-typescript-1-6.aspx) 一起使用
【问题讨论】:
-
奇怪。使用 1.6.2 从命令行编译时对我来说效果很好。
-
Typescript 安装非常糟糕。我的环境路径中有 Typescript/Typescript/1.2/Typescript/1.3/Typescript/1.4。当您认为自己是 1.6 时,您可能没有引用。
标签: visual-studio-2013 typescript typescript1.6