擅长:python、mysql、java
<p>正如@AlexPalcuie上面的答案一样,您可以使用<a href="https://facebook.github.io/react/docs/jsx-spread.html#spread-attributes" rel="nofollow">object spread</a>来完成python <code>**</code>操作符所做的工作。在</p>
<p>所以这相当于上面的代码:</p>
<pre><code>var CommentBox = React.createClass({
render: function () {
var CommentNodes = this.props.data.map(function (comment) {
return (
<Comment {...comment}>
</Comment>
);
});
return (
<div className="comment-box">
{CommentNodes}
</div>
);
}
});
</code></pre>