![在此处输入图片描述] [在此处输入链接描述] 1)
onPress = {()=> this.navigation.navigate('DrawerOpen')} 不是警告错误:“评估enter link description here _class.navigation.navigate”
onPress = {()=> this.navigation.navigate('DrawerOpen')} 不是警告错误:“评估_class.navigation.navigate”
答案 0 :(得分:0)
尝试一下onPress ={ ( ) => this.props.navigation.navigate(' DrawerOpen')}
答案 1 :(得分:0)
export default class Source extends React.Component {
static navigationOptions = {
title: 'India',
headerStyle: {
backgroundColor: colors.primary,
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
alignItems: 'center',
},
headerLeft: (
<Button
onPress={()=>this.navigation.Drawer.open()}
title="Info"
color="#fff"
/>
),
};
答案 2 :(得分:0)
尝试一下:
export default class Source extends React.Component {
static navigationOptions = ({navigation}) => {
return {
title: 'India',
headerStyle: {
backgroundColor: colors.primary,
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
alignItems: 'center',
},
headerLeft: (
<Button
onPress={()=> navigation.navigate(' DrawerOpen')}
title="Info"
color="#fff"
/>
),
}
}
}
答案 3 :(得分:0)
在使用导航导入withNavigation
的组件中,并在javascript文件的底部导出您的组件withNavigation()
。
import { withNavigation } from 'react-navigation';
class YourAwesomeComponent from React.Component {
{your component code}
}
export default withNavigation(YourAwesomeComponent);
然后,您将可以在组件中使用导航道具。 This section in the React Navigation documentation explains further