我正在尝试在另一个组件中使用一个组件,就像在 React 中一样...
var ContentBox = React.createClass({
render: function () {
return (
<div>
<div className="container-fluid">
<div className="box center-block">
{this.props.children}
</div>
</div>
</div>
);
}
});
var Quotesection = React.createClass({
render:function () {
return(
<ContentBox><h1 className="text-center">Example text</h1></ContentBox>
);
}
});
ReactDOM.render(<ContentBox/>, document.getElementById('app'));
但我得到的只是盒子而不是盒子和盒子里的报价。如果有人可以提供帮助,那就太好了。
最佳答案
在您提供的代码中,您根本没有使用 Quotesection
。
试试这个:
ReactDOM.render(<Quotesection/>, document.getElementById('app'));
关于javascript - React.js 如何在另一个组件中使用一个组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39008573/