阵营本地导航 - 绘制选项 - 增加一个开关
问题描述:
我使用https://reactnavigation.org/docs/intro/阵营本地导航 - 绘制选项 - 增加一个开关
我想补充一个开关,或者转换成平局 - 而不是链接到另一个页面。
我想看的是,拉开 - 然后显示一个切换开关替代选项。用户应该能够在没有绘制关闭的情况下打开和关闭。
任何人都知道这是可能的吗?
答
U可以使用DrawerNavigator中的contentComponent为抽屉使用自定义React组件。
{
drawerWidth: 200,
drawerPosition: 'right',
contentComponent: props => <ScrollView><DrawerItems {...props} /></ScrollView>
}
contentComponent
可以是自定义的阵营类u可以写它由什么ü希望。
提供定制contentComponent
可以很容易地覆盖由反应导航中使用的默认组件:
import { DrawerItems } from 'react-navigation';
const CustomDrawerContentComponent = (props) => (
<View style={style.container}>
<DrawerItems {...props} />
</View>
);
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
参见:https://reactnavigation.org/docs/navigators/drawer
定制抽屉例如:https://developerlife.com/2017/04/15/navigation-and-styling-with-react-native/