0
在这样的反应原生中使用flex是一个好主意吗?创建你自己的组件来恢复flex的值?我之前使用bootstrap网格系统,现在我试图学习反应原生。我可以使用react-native flex类似于引导行/列系统吗?
有什么办法可以在堆栈上使用react-native bootstrap来显示这个例子吗?
let FlexContainer = ({direction,children}) =>{
console.log(direction)
var style = {
flexDirection:direction || 'row',
display:'flex',
width:'100%',
height:'100%'
}
return(<div style={style}>{children}</div>)
}
let FlexBox = ({val, color, children}) => {
return (
<div style={{backgroundColor:color, flex:val}}>{children}</div>
)
}
class LayoutExample extends React.Component {
constructor(props){
super(props)
}
render(){
return(
<div className='screen'>
<FlexContainer>
<FlexBox val={1} />
<FlexBox color="blue" val={1} />
<FlexBox color="red" val={1} />
</FlexContainer>
</div>
)
}
}
ReactDOM.render(<LayoutExample />,document.getElementById('example'))
.screen {
width:400px;
height:300px;
border:2px solid black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js"></script>
<div id="example"></div>
是这种方法有效与否?
我必须得到我的大脑flex,谢谢你的帖子! –