扫码关注官方订阅号
怎么循环输出<ul></ul>中的内容,并且每次输出的内容不一样?
闭关修行中......
// tutorial7.js var Comment = React.createClass({ rawMarkup: function() { var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); return { __html: rawMarkup }; }, render: function() { return ( <p className="comment"> <h2 className="commentAuthor"> {this.props.author} </h2> <span dangerouslySetInnerHTML={this.rawMarkup()} /> </p> ); } }); // tutorial8.js var data = [ {id: 1, author: "Pete Hunt", text: "This is one comment"}, {id: 2, author: "Jordan Walke", text: "This is *another* comment"} ]; // tutorial10.js var CommentList = React.createClass({ render: function() { var commentNodes = this.props.data.map(function(comment) { return ( <Comment author={comment.author} key={comment.id}> {comment.text} </Comment> ); }); return ( <p className="commentList"> {commentNodes} </p> ); } }); // tutorial9.js var CommentBox = React.createClass({ render: function() { return ( <p className="commentBox"> <h1>Comments</h1> <CommentList data={this.props.data} /> </p> ); } }); ReactDOM.render( <CommentBox data={data} />, document.getElementById('content') );
https://facebook.github.io/react/docs/tutorial.html#hook-up-the-data-model
用map做循环
现在是输出5个星号?
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
https://facebook.github.io/react/docs/tutorial.html#hook-up-the-data-model
用map做循环
现在是输出5个星号?