Javascript Header Menu On Press在React native模式下不工作
onPress={()=>this.navigation.navigate('drawerropen')} 不工作 错误:“评估\u类.导航.导航” 试试这个Javascript Header Menu On Press在React native模式下不工作,javascript,react-native,Javascript,React Native,onPress={()=>this.navigation.navigate('drawerropen')} 不工作 错误:“评估\u类.导航.导航” 试试这个onPress={()=>this.props.navigation.navigate('drawerropen')}导出默认类源代码扩展React.Component{ 静态导航选项={ 标题:"印度",, 头型:{ 背景颜色:colors.primary, }, 标题颜色:“#fff”, 头饰样式:{ fontWeight:'粗体',
onPress={()=>this.props.navigation.navigate('drawerropen')}
导出默认类源代码扩展React.Component{
静态导航选项={
标题:"印度",,
头型:{
背景颜色:colors.primary,
},
标题颜色:“#fff”,
头饰样式:{
fontWeight:'粗体',
对齐项目:“居中”,
},
左校长:(
this.navigation.Drawer.open()}
title=“Info”
color=“#fff”
/>
),
};
试试这个:
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"
/>
),
}
}
导出默认类源扩展React.Component{
静态导航选项=({navigation})=>{
返回{
标题:"印度",,
头型:{
背景颜色:colors.primary,
},
标题颜色:“#fff”,
头饰样式:{
fontWeight:'粗体',
对齐项目:“居中”,
},
左校长:(
navigation.navigate('drawerropen')}
title=“Info”
color=“#fff”
/>
),
}
}
}在使用导航的组件中,使用导航导入
,,在javascript文件的底部,使用导航()导出组件
然后,您将能够在组件中使用导航道具 !!onPress={()=>this.navigation.navigate('drawerropen')}不是警告错误:“evaluation\u class.navigation.navigate”!您好,欢迎来到SO,请检查您的问题,以便我们更容易理解您的代码并为您提供帮助。也许能帮你。问题是导航中的板条箱。我试试兄弟。。但是道具不起作用..你能粘贴更多的代码吗?检查代码。。可能会弄错“static navigationOptions=”我们在这里写什么?添加导航但不起作用..是的,我尝试了但没有解决我的解决方案。。请检查我的密码。
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"
/>
),
}
}
import { withNavigation } from 'react-navigation';
class YourAwesomeComponent from React.Component {
{your component code}
}
export default withNavigation(YourAwesomeComponent);