大部分APP项目页面以TabBar和NavigationBar为主,默认创建的项目中没有navigation,需要引入@react-navigation组件。
1、
npm install @react-navigation/native
1)安装到Expo管理的项目中
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view
2)安装到本地项目中
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
iOS安装完后需要pod install
npx pod-install ios
2、使用,因为需要在整个项目中使用,所以要在项目的入口文件中引入NavigationContainer
import 'react-native-gesture-handler';
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
网友评论