我对React Native很熟悉,但对ReactJS却不太了解。我有一个样式问题:我正在为一个爱好项目https://github.com/rcdexta/react-trello修改此lib,而我感兴趣的代码如下:
// Render Method
return (
<BoardDiv style={style} {...otherProps} draggable={false}>
<UpdateModal
isOpen={this.state.isOpen}
onClick={this.closeModal.bind(this)}
card={this.state.card}
onRequestClose={this.closeModal}/>
<PopoverWrapper>
<Container
orientation="horizontal"
onDragStart={this.onDragStart}
dragClass={laneDragClass}
dropClass=""
onDrop={this.onLaneDrop}
lockAxis="x"
getChildPayload={index => this.getLaneDetails(index)}
groupName={this.groupName}>
{reducerData.lanes.map((lane, index) => {
const {id, droppable, ...otherProps} = lane
const laneToRender = (
<Lane
key={id}
boardId={this.groupName}
id={id}
getCardDetails={this.getCardDetails}
onCardClick={(cardId, metadata, laneId) => {
const allCards = [].concat(...this.props.reducerData.lanes.map((lane) => lane.cards))
const cardData = allCards.filter((e) => e.id === cardId)[0]
this.modifyCardTitle(cardData)
}}
index={index}
droppable={droppable === undefined ? true : droppable}
{...otherProps}
{...passthroughProps}
/>
)
return draggable && laneDraggable ? <Draggable key={lane.id}>{laneToRender}</Draggable> :
<span key={lane.id}>{laneToRender}</span>
})}
</Container>
</PopoverWrapper>
{canAddLanes && (
<Container orientation="horizontal">
{editable && !addLaneMode ? (
<LaneSection style={{width: 200}}>
<NewLaneButton onClick={this.showEditableLane}>{addLaneTitle}</NewLaneButton>
</LaneSection>
) : (
addLaneMode && this.renderNewLane()
)}
</Container>
)}
</BoardDiv>
)
但是渲染看起来像这样:
<div class="react-trello-board sc-bdVaJa eBPLjG" data="[object Object]" draggable="false">
<div> <!--The problem-->
<div class="smooth-dnd-container horizontal">
<section title="will_apply" draggable="false" class="react-trello-board sc-htpNat dJewwL"
style="width: 25%;">
</section>
</div>
</div>
我的问题如下:我不知道React为什么创建标记为问题的div(请参见上面的代码段),并且由于display: flex
没有在其中传播(它显示{{ 1}})。
我有什么选择?
我应该用block
覆盖和设置所有div
的样式吗?我可以看到创建此display: flex; flex:1
的位置和原因吗?