【发布时间】:2016-01-14 19:39:34
【问题描述】:
在这里,我有两个组件。一个是 ComponentOne,另一个是 ComponentTwo。目前我只渲染一个组件,即 ComponentTwo。
var ComponentOne = React.createClass({
render: function() {
<div className="card">
<h2>Component one</h2>
</div>
}
});
var ComponentTwo = React.createClass({
render: function() {
<div className="card">
<h2>Component two</h2>
<button>Insert</button>
</div>
<ComponentOne />
}
});
如果我单击插入按钮 ComponentOne 将在 componenttwo 类元素卡之后插入。如何用 reactjs 实现这一点?
【问题讨论】:
-
这个怎么样 .. 在 component2 上添加一个属性作为 "c1Hidden" 最初设置为 true 。在按钮上添加一个 onClick 事件和一个在单击按钮时将 chHidden 更改为 false 的方法。在
-
@Sathya,我的回答有帮助吗?如果有,请接受。
标签: javascript html css reactjs