3

我想并排放置 3 个输入。我有如下代码,并且在每次迭代中我都希望三个组件并排。可能吗?

{
    this.state.features.length > 0 ?
        this.state.features.map((feature) => {
            return (
                <div>
                    <BooleanInput key={feature} source={this.assignIsFeatureActiveProp(feature)} label={feature} />
                    <DisabledInput source="id" label="Value" defaultValue={feature} />
                    <TextInput source={this.assignFeatureValueProp(feature)} label="Value" />
                </div>
            )
        })
        :
        null
}
4

1 回答 1

6

您可以传递样式道具,例如,使用以下样式。

style={{ display: 'inline', float: 'left', marginLeft: '20px' }}

上面的代码看起来像

{
    this.state.features.length > 0 ?
        this.state.features.map((feature) => {
            return (
                <div>
                    <BooleanInput key={feature} source={this.assignIsFeatureActiveProp(feature)} label={feature} style={{ display: 'inline', float: 'left', marginLeft: '20px' }} />
                    <DisabledInput source="id" label="Value" defaultValue={feature} style={{ display: 'inline', float: 'left', marginLeft: '20px' }} />
                    <TextInput source={this.assignFeatureValueProp(feature)} label="Value" style={{ display: 'inline', float: 'left', marginLeft: '20px' }} />
                </div>
            )
        })
        :
        null
}
于 2018-06-18T19:28:40.653 回答