我試圖運行一個簡單的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他們不喜歡不要用()來調用它中的函數,但它可以工作。你能解釋爲什麼嗎? –