我试图运行一个简单的React组件,但不知道为什么这不起作用。反应:在变量内调用方法
由于某种原因,addRows
未运行。有人能解释为什么吗?
var CreateRows = React.createClass({
addRows : function(){
return (
<tr>
<td>Morgan</td>
<td>[email protected]</td>
</tr>
)
},
render: function(){
return (
<tbody>
{this.addRows}
</tbody>
)
}
});
调用方法 - {this.addRows()} –
谢谢。我一直在关注这个教程 - https://tylermcginnis.com/react-js-tutorial-pt-1-a-comprehensive-guide-to-building-apps-with-react-js-8ce321b125ba#.5w3ath7hc他们不喜欢不要用()来调用它中的函数,但它可以工作。你能解释为什么吗? –