首页 > react 如何组合

react 如何组合

例如现在有Button和 Nav两个类
能不能实现这样

var Button, Nav; //实现省略
React.render(
    <Nav> 
        <Button></Button>
    </Nav>
, docuememt.getElementById('div'))

这样 Nav类该怎么写


Nav.jsx

var Nav = React.createClass({
  render: function() {
    return (
      <div className="commentBox">
        Hello, world! I am a CommentBox.
        { this.props.children }
      </div>
    );
  }
});

index.jsx

React.render(
        <Nav>
            <button>BUTTON</button>
        </Nav>,
        document.getElementById('div')
      );

看plunker


var Nav = React.createClass({

render:function(){
    <div>...</div>
}

})

【热门文章】
【热门文章】