2020-04-23

安装 依赖
npm install @react-navigation/native
npm install @react-navigation/stack
npm install @react-navigation/bottom-tabs
npm install @react-navigation/material-top-tabs react-native-tab-view
//原生导航
//堆栈导航
//底部导航
//顶部安卓导航

npm install
react-native-reanimated
react-native-gesture-handler
react-native-screens
react-native-safe-area-context @react-native-community/masked-view

配置

android/app/build.gradle dependencies 对象里面

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

堆栈导航

导入
import {NavigationContainer} from '@react-navigation/native';
//  导航容器
import {createStackNavigator} from '@react-navigation/stack';
//  导入创建堆栈导航方法

创建导航需要的页面
 <NavigationContainer>
        <Stack.Navigator>
          <Stack.Screen 
            name="Home" 
            component={Home}
                />
          <Stack.Screen 
            name="Details" 
            component={Details}         

            />
        </Stack.Navigator>
      </NavigationContainer>

页面的跳转

this.props.navigation

push推入堆栈
replace 替换当前页面
goBack() 返回
popToTop() 回到顶层
堆栈导航参数

title:"详情", 标题
headerStyle:{backgroundColor:"#f30"}, 标题栏样式
headerTintColor:"#FFF", 文本提示颜色
headerTitleStyle:{fontWeight:'bold'}, 标题样式
headerRight:()=>(<Text style={{color:"#fff",paddingRight:15}}>设置</Text>)标题右侧

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 从 0 搭理后台管理系统 初始化项目 提示选择一个preset (预置项) 选择自自定义选项 路由是否使用...
    想改名叫孟健康阅读 312评论 0 2
  • #react-native模拟器报错信息提示: Could not install the app on the ...
    迷途小书虫88阅读 107评论 0 0
  • 灵修笔记 祷告:慈爱的天父,我的神,感谢赞美你!感谢你,将我拣选,感谢你,让我回心转意,感谢你长阔高深的爱,感谢你...
    以诺以惜阅读 2,703评论 0 0
  • 黑夜 可能不是最安静的 白天 可能不是最喧闹的 成功 可能也意味着失败 失败 可能也意味着成功 谁在黑夜醒来狂欢 ...
    林月小镇阅读 102评论 0 0
  • 姑娘在我左边举手要回答问题,二宝在我右边练习翻身,好吧,我成了夹心饼干喽。 随后关灯了,想起熄灯之前的读书时刻,看...
    秋尧的润物空间阅读 376评论 0 1