我有一个从"测试"页面到" testDetails"页面的链接。但是,当我在" testDetails"页面上单击此。这是我的index.js。我真的不知道该怎么到。请我做错了什么
const HomeScreen = createStackNavigator({
Home: {
screen: Home,
navigationOptions: ({navigation}) => ({
})
}
});
const LoginScreen = createStackNavigator({
Home: {
screen: Login,
navigationOptions: ({navigation}) => ({
})
}
});
const SignupScreen = createStackNavigator({
Signup: {
screen: Signup,
navigationOptions: ({navigation}) => ({
})
}
});
const TestsScreen = createStackNavigator({
Tests: {
screen: Tests,
navigationOptions: ({navigation}) => ({
headerTitleStyle: {
fontWeight: '400',
color: '#333',
fontFamily: 'Nunito-Regular',
fontSize: 18
},
headerStyle: {
elevation: 0, //remove shadow on Android
shadowOpacity: 0, //remove shadow on iOS
fontWeight: 400,
},
title: "Consumer tests",
headerLeft:(<Icon.Button name="menu" size={35}
backgroundColor="transparent" color="#2a486c" onPress={() =>
navigation.dispatch(DrawerActions.toggleDrawer())}>
</Icon.Button>
),
})
}
});
const TestDetailsScreen = createStackNavigator({
TestDetails: {
screen: TestDetails,
navigationOptions: ({navigation}) => ({
})
}
});
const SettingsScreen = createStackNavigator({
Settings: {
screen: Settings,
navigationOptions: ({navigation}) => ({
title: "Settings",
headerLeft:(<Icon.Button name="arrow-back" backgroundColor="transparent" color="black" onPress={() => navigation.dismiss()}>
<Text style={{fontSize: 15}}></Text>
</Icon.Button>
),
})
},
});
const drawernav = createDrawerNavigator({
Home: {
screen: HomeScreen,
},
Login: {
screen: LoginScreen,
},
SignUp: {
screen: SignupScreen,
},
Tests: {
screen: TestsScreen,
},
TestDetails: {
screen: TestDetailsScreen,
},
Settings: {
screen: SettingsScreen,
},
},{
contentComponent: SideMenu,
});
AppRegistry.registerComponent(appName, () => createAppContainer(drawernav));
pl我在做什么错
const LoginScreen = createStackNavigator({
Home: {
screen: Login,
navigationOptions: ({navigation}) => ({
})
}
})
为什么要回家:在这里?
您可以添加控制台中的信息,还是未收到错误或警告?请记住,请始终引用官方指南https://facebook.github.io/reaeact-native/docs/navigation
我已经确认了react-native-navigation
定义,如下面的代码段。 goBack()
和goBack(null)
相同!
回到您的问题:像@michael帖子一样,您最好检查导航堆栈拳头
export interface NavigationScreenProp<S, P = NavigationParams> {
state: S;
dispatch: NavigationDispatch;
goBack: (routeKey?: string | null) => boolean;
dismiss: () => boolean;
navigate(options: {
routeName:
| string
| {
routeName: string;
params?: NavigationParams;
action?: NavigationNavigateAction;
key?: string;
};
params?: NavigationParams;
action?: NavigationAction;
key?: string;
}): boolean;