Javascript 部分组件显示在屏幕外

Javascript 部分组件显示在屏幕外,javascript,react-native,styling,Javascript,React Native,Styling,我使用多重渲染方法渲染按钮,但我发现很难管理它的样式 这是我渲染按钮的代码 const [abc, setAbc] = useState([ { type: 'aa'},{ type: 'bb'},{ type: 'cc'},{ type: 'dd'}, { type: 'ee'},{ type: 'ff'},{ type: 'gg'},{ type: 'hh'}, { type: 'ii'},{ type: 'jj'},{ type: 'kk'},{ type: 'll'}, { type:

我使用多重渲染方法渲染按钮,但我发现很难管理它的样式

这是我渲染按钮的代码

 const [abc, setAbc] = useState([
{ type: 'aa'},{ type: 'bb'},{ type: 'cc'},{ type: 'dd'},
{ type: 'ee'},{ type: 'ff'},{ type: 'gg'},{ type: 'hh'},
{ type: 'ii'},{ type: 'jj'},{ type: 'kk'},{ type: 'll'},
{ type: 'mm'},{ type: 'nn'},{ type: 'oo'},{ type: 'pp'},
{ type: 'qq'},{ type: 'rr'},{ type: 'ss'},{ type: 'tt'},
{ type: 'uu'},{ type: 'vv'},{ type: 'ww'},{ type: 'xx'},
{ type: 'yy'},{ type: 'zz'},
])

const renderedABC =  abc.map(item => {
    return <Button key={item.type} title={item.type}/>;
  })
const[abc,setAbc]=useState([
{type:'aa'},{type:'bb'},{type:'cc'},{type:'dd'},
{type:'ee'},{type:'ff'},{type:'gg'},{type:'hh'},
{type:'ii'},{type:'jj'},{type:'kk'},{type:'ll'},
{type:'mm'},{type:'nn'},{type:'oo'},{type:'pp'},
{type:'qq'},{type:'rr'},{type:'ss'},{type:'tt'},
{type:'uu'},{type:'vv'},{type:'ww'},{type:'xx'},
{type:'yy'},{type:'zz'},
])
const renderedABC=abc.map(项=>{
返回;
})
它显示的像

我想让更多的行,并显示它的一种单独。至少它填补了“空白”
在底部。

您应该用一些
包装按钮,并添加
flex:1
作为样式

请试一试

const renderedABC =  (
    <View style={{flex: 1}}>
        {abc.map(item => <Button key={item.type} title={item.type}/>)
    </View>
);
const renderedABC=(
{abc.map(项=>)
);

必须使用flex:1样式以呈现组件。如果要逐行呈现这些组件,可以使用flexDirection:row。默认值为“column”。在您的情况下,不需要使用flexDirection

renderedABC(){
   return(
       <View style={{flex: 1}}>
           {abc.map(item => <Button key={item.type} title={item.type}/>)
       </View>
   )
};
renderedABC(){
返回(
{abc.map(项=>)
)
};