react实现汉堡_reactjs – 所有顶级屏幕标题(使用抽屉)标题中的react-navigation汉堡包图标?...

我可以为某些内容设置“通用”标题选项,例如将标题颜色设置为白色:

// example screens

const SettingsScreen = () => SettingsScreen...

const List = () => List...

const Item = () => Item...

// create an object to pass on to relevant screens

const navigationOptions = {

header: {

style: {

backgroundColor: '#fff'

}

},}

// MAIN SCREEN : a screen showing a list with ability to click on an list item and go to a detail page

// ============================

const ListScreens = StackNavigator({

List: { screen: List,navigationOptions: navigationOptions },//show a hamburger menu

Item: { screen: Item,// this is a detail page,so don not show a hamburger menu,rather show a back button

});

const SettingsContainer = StackNavigator({

Settings: { screen: SettingsScreen },});

// LOGGED IN DRAWER VIEW : top-level component is a drawer with two menu items (main and settings)

// ============================

const LoggedIn = DrawerNavigator({

Main: { screen: ListScreens },Settings: { screen: SettingsContainer },});

//... do stuff for root component

在DrawerNavigation菜单级别为所有路线添加汉堡菜单的最佳做法是什么?我想让这个流行音乐打开抽屉.没有访问props.navigation,除非我在每个组件内部……只是状态和参数.我是否需要复制每个文件中的代码?

static navigationOptions = {

title: ({ state }) => {

if (state.params.mode === 'info') {

return `${state.params.user}'s Contact Info`;

}

return `Chat with ${state.params.user}`;

},header: ({ state,setParams }) => {

// The navigation prop has functions like setParams,goBack,and navigate.

let right = (

title={`${state.params.user}'s info`}

onPress={() => setParams({ mode: 'info' })}

/>

);

if (state.params.mode === 'info') {

right = (

title="Done"

onPress={() => setParams({ mode: 'none' })}

/>

);

}

return { right };

},..

相关问题(可能):

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值