结构:
第一层——CommentBox
第二层——CommentList
第三层——Comment
第二层——CommentForm
1、JSX语法:
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
CommentBox
</div>
);
}
});
ReactDOM.render(
<CommentBox />,
document.getElementById('commentBox')
);
JSX是XML式的语法,预编译器会将语法糖转换成单纯的JavaScript:
var CommentBox = React.createClas

本文深入探讨了使用React构建评论框的过程,包括JSX语法的优势,React.createClass()创建组件以及ReactDOM.render()启动框架。文章还介绍了如何添加子组件CommentList和CommentForm,利用props传递数据,并讲解了Markdown的使用。针对Markdown转换为HTML的问题,提出了使用第三方库remarkable进行文本转换的解决方案。
&spm=1001.2101.3001.5002&articleId=70502495&d=1&t=3&u=ae4a02b2c3fe4f32a4e5f58331909fcf)
1054

被折叠的 条评论
为什么被折叠?



