React-Native - 如何在 Native Base 中动态创建选项卡?
React-Native - How to create tabs dynamically in Native Base?
我想使用本机基础库中的选项卡,但我不知道如何动态创建选项卡?
在官方文档中,标签是手动添加的。但是如何动态添加标签?
您需要使用一些循环创建选项卡组件数组,然后呈现组件数组
例如:
export default class ThemeTabsExample extends Component {
makeTabs = ()=>{
//make array of components which finally look like this one :
//[<CustomeTabComponent tabLabel='One' />,
// <CustomeTabComponent tabLabel='two' />,
// <CustomeTabComponent tabLabel='three' />
// ]
// hint :
Output = []
for ....
Output.push(<CustomeTabComponent />)
}
render() {
let Tabs = this.makeTabs(....) // you can use 'loop' here instead of calling Function
return (
<Container>
<Content>
<Tabs>
{Tabs}
</Tabs>
</Content>
</Container>
);
}
}
我想使用本机基础库中的选项卡,但我不知道如何动态创建选项卡?
在官方文档中,标签是手动添加的。但是如何动态添加标签?
您需要使用一些循环创建选项卡组件数组,然后呈现组件数组 例如:
export default class ThemeTabsExample extends Component {
makeTabs = ()=>{
//make array of components which finally look like this one :
//[<CustomeTabComponent tabLabel='One' />,
// <CustomeTabComponent tabLabel='two' />,
// <CustomeTabComponent tabLabel='three' />
// ]
// hint :
Output = []
for ....
Output.push(<CustomeTabComponent />)
}
render() {
let Tabs = this.makeTabs(....) // you can use 'loop' here instead of calling Function
return (
<Container>
<Content>
<Tabs>
{Tabs}
</Tabs>
</Content>
</Container>
);
}
}