2
在DOM中多次使用React.render()可以吗?
我想使用React在整个DOM中多次添加组件。这个小提琴显示了我要执行的操作,并且不会引发任何错误。这是代码: HTML: <div id="container"> <!-- This element's contents will be replaced with the first component. --> </div> <div id="second-container"> <!-- This element's contents will be replaced with the second component. --> </div> JS: var Hello = React.createClass({ render: function() { return <div>Hello {this.props.name}</div>; } }); React.render(<Hello name="World" />, document.getElementById('container')); React.render(<Hello …
107
reactjs