reactjs - 我如何在 react 中合并两个组件

在 Angular 中,我可以在一个元素上应用两个指令。

<div dir-one dir-two></div>

React 中的等价物是什么?

最佳答案

你可以这样做

var FirstComponent = React.createClass({
    render: function() {
        return <div>FirstComponent</div>;
    }
});

var SecondComponent = React.createClass({
    render: function() {
        return <div>SecondComponent</div>;
    }
});

var MainComponent = React.createClass({
    render: function() {
        return <div>
            <FirstComponent />
            <SecondComponent />
        </div>;
    }
});

Example

https://stackoverflow.com/questions/33645243/

相关文章:

python - 统一码编码错误 : 'ascii' codec can't encode char

caching - 查找处理器的多级缓存的 AMAT 和 CPI

r - 将 3D 表面拟合到点数据集 [R]

windows - 使用 vmware 机器进行内核调试

sql - 基于两个表的select CASE语句

verilog - systemverilog 中逻辑语句的非常量索引

php - 检查字符串中是否存在多个单词之一?

three.js - 是否可以在 Three.js 中使用带缓冲几何的三角形带?

azure - 单个 Azure Web App 的多个实例是否共享单个磁盘?

c# - 在列表中查找一个属性包含重复值的对象