我是swift的新手,我正试图在原生基地切换抽屉。打开抽屉工作正常,但一旦点击相同的按钮,它就不会切换(不关闭)。代码如下:
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Dimensions,
Text,
View
} from 'react-native';
import { Drawer } from 'native-base';
export default class App extends Component {
closeDrawer=()=> {
this._drawer._root.close()
};
openDrawer=()=> {
this._drawer._root.open()
};
render() {
return (
<Drawer
openDrawerOffset={(Dimensions.get('window').width) / 2}
styles={drawerStyles}
ref={(ref) => { this._drawer = ref; }}
content={<MenuBar navigator={this._navigator} />}
>
<View style={{ flex: 1 }} >
<View>
<Header openDrawerClicked={this.openDrawer}/>
</View>
</View>
</Drawer>
);
}
}
const drawerStyles = {
drawer: { paddingTop: 113, shadowColor: '#000000', shadowOpacity: 0.5, shadowRadius: 3, paddingBottom:60},
}
输出