无法解析模块@react-navigation/native 在项目内或这些目录中找不到@react-navigation/native:

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

错误: 错误:无法从 D: 解析模块 @react-navigation/native eact-native-practice pp1\App.tsx:在项目或这些目录中找不到@react-navigation/native:

error

我的代码:

import React from "react";
import { View, Text, StyleSheet, ScrollView, SafeAreaView, TextInput, TouchableOpacity } from "react-native";
import { useNavigation } from '@react-navigation/native';

import Icon from 'react-native-vector-icons/FontAwesome';
import Ionicons from 'react-native-vector-icons/Ionicons';

import Button from './components/Button';
import InputFeild from './components/InputFeild';

const App = () =>{
    const navigation = useNavigation();

    return(
        <SafeAreaView style={styles.container}>
            <View style={styles.emptyProfile}>
                <Ionicons name="person-outline"  size={50}/>
            </View>
            <View style={styles.inputFeilds}>
                <InputFeild name="user_name" banner="at-outline" secutiry={false}/>
                <InputFeild name="password" banner="lock-closed-outline" secutiry={true}/>
            </View>
            <View style={styles.actions}>
                <Button buttonIcon="log-in-outline" text="Sign In" buttonActivated={true}/>
                <Button buttonIcon="person-add-outline" text="New user? Sign Up" buttonActivated={false} 
                    onPress={() => {
                        
                    }}
                />
            </View>
        </SafeAreaView>
    );
};

export default App;
typescript react-native react-navigation react-native-navigation
2个回答
1
投票

在您的项目中安装这些包并重新启动项目

npm install @react-navigation/native

查看这些文档https://reactnavigation.org/docs/getting-started/


0
投票

从“react”导入React; 从“react-native”导入{ View、Text、StyleSheet、ScrollView、SafeAreaView、TextInput、TouchableOpacity }; 从 '@react-navigation/native' 导入 { useNavigation };

从“react-native-vector-icons/FontAwesome”导入图标; 从“react-native-vector-icons/Ionicons”导入 Ionicons;

从“./components/Button”导入按钮; 从'./components/InputFeild'导入InputFeild;

常量应用程序 = () =>{ 常量导航 = useNavigation();

return(
    <SafeAreaView style={styles.container}>
        <View style={styles.emptyProfile}>
            <Ionicons name="person-outline"  size={50}/>
        </View>
        <View style={styles.inputFeilds}>
            <InputFeild name="user_name" banner="at-outline" secutiry={false}/>
            <InputFeild name="password" banner="lock-closed-outline" secutiry={true}/>
        </View>
        <View style={styles.actions}>
            <Button buttonIcon="log-in-outline" text="Sign In" buttonActivated={true}/>
            <Button buttonIcon="person-add-outline" text="New user? Sign Up" buttonActivated={false} 
                onPress={() => {
                    
                }}
            />
        </View>
    </SafeAreaView>
);

};

导出默认应用程序;

© www.soinside.com 2019 - 2024. All rights reserved.