【发布时间】:2015-07-11 19:50:53
【问题描述】:
我正在尝试实现一个Read More 链接,该链接扩展为显示
点击后更多文字。我正在尝试以 React 的方式做到这一点。
<!--html-->
<div class="initialText">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
<a>
Read More
</a>
</div>
<div class="fullText">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
/* JavaScript */
/* @jsx DOM */
var component = React.createClass({
getInitialState: function() {
return {
expanded: false
};
},
expandedText: function() {
this.setState({
expanded: true
});
},
render: function() {
return (
<div>
</div>
);
}
});
我是 React 新手。我不确定如何处理渲染方法中的所有内容。如何在纯 React 中实现此功能?
【问题讨论】:
标签: javascript html css dom reactjs