React原生导航5堆栈Navigator无法在生产中使用。

问题描述 投票:0回答:1

我用的是 ReactNavigation 用于标签导航器和 stackNavigator. 它的工作100%的开发,模式,但它的 stacNavigator 在生产版本上无法使用。该应用程序没有崩溃,只是没有在页面中导航。但标签导航器工作正常。

有人遇到这个问题吗?

我已经打开了一个 发出.

react-native react-native-android react-navigation
1个回答
0
投票

应用程序.js

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import AdminHome from './AdminScr/AdminHome
import AdmLogin from './AdminScr/AdminLogin';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
    function App() {
       return (
          <View style={styles.container}  >
             <Stack.Navigator style={{ backgroundColor: '#e91e63' }}>

               <Stack.Screen name="AdmHome" component={AdminHome} options={{
                  title: 'Admin Home',
                  headerStyle: {
                   //backgroundColor: '#1e90ff',
                    backgroundColor: '#E66E2F'
                    },
                  headerTintColor: '#fff',
                  headerTitleStyle: {
                  fontWeight: 'bold',
                 },
                }}
               />

               <Stack.Screen name="AdmLogin" component={AdmLogin} options={{
                     title: 'Admin Login',
                      headerStyle: {
                      backgroundColor: '#E66E2F',
                         },
                     headerTintColor: '#fff',
                    headerTitleStyle: {
                    fontWeight: 'bold',
                      },
                   }} 
                />
            </Stack.Navigator>

    </View>
  );
}

export default () => {
  return (
    <NavigationContainer>
      <App />
    </NavigationContainer>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#e91e63',

  },
});

调用 adminLogin.js 页面。

//For Arrow Function

   const AdmLogin=(props)=> {   //Passing props in fat area like (props).
           return (
              <View>
                 <TouchableOpacity style={styles.signinbutton} onPress={() => props.navigation.navigate("AdmHome")}  >
                      <Text style={styles.buttonText}> Sign In</Text>
                 </TouchableOpacity>
              </View>
          )}

//For Class Method

       <TouchableOpacity style={styles.signinbutton} onPress={() => this.props.navigation.navigate("AdmHome")}  >
              <Text style={styles.buttonText}> Sign In</Text>
       </TouchableOpacity>
© www.soinside.com 2019 - 2024. All rights reserved.