所以我在index.js
中有一个名为openControlPanel的函数class App extends Component {
closeControlPanel = () => {
this._drawer.close()
};
openControlPanel = () => {
this._drawer.open()
};
render() {
return (
<Drawer
ref={(ref) => this._drawer = ref}
content={<Promo />}
>
<Root />
</Drawer>
);
}
}
export default App;
我想在router.js
中的StackNavigator中调用这些打开和关闭函数export const Root = StackNavigator({
Tabs: {
// screen: Object.assign(Tabs,{navigationOptions}),
screen: Tabs,
navigationOptions: ({_drawer}) => ({
title:'hoho',
headerLeft: <Button buttonStyle={{marginLeft:10}} title="DR" onPress={() => _drawer.open()} />
})
}});
实际上我可以使用react-navigation中的默认DrawerNavigator,但似乎抽屉不是真正可定制的......