RN 使用react-navigation写可以滚动的横向导航条(expo项目)

装包:

bash 复制代码
yarn add @react-navigation/material-top-tabs react-native-tab-view
bash 复制代码
npx expo install react-native-pager-view
javascript 复制代码
import React from 'react'
import { View, Text, ScrollView, SafeAreaView } from 'react-native'
import { Icon } from '../../../../../component/light'
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'
import useList from './useList'
import styles from './styles'

const HomeScreen = () => {
  return (
    <ScrollView style={styles.mMeTabsScrollView}>
      <Text>666</Text>
    </ScrollView>
  )
}

const SettingsScreen = () => {
  return (
    <ScrollView style={styles.mMeTabsScrollView}>
      <Text>666</Text>
    </ScrollView>
  )
}

const Tab = createMaterialTopTabNavigator()

export default function Home(props) {
  const { index, userInfo, handleSetIndex, handleJumpPage, handleQuit } =
    useList(props)

  return (
    <View style={{ flex: 1 }}>
      <Tab.Navigator
        screenOptions={{
          tabBarScrollEnabled: true,
        }}
      >
        <Tab.Screen name="Home" component={HomeScreen} />
        <Tab.Screen name="Settings" component={SettingsScreen} />
        <Tab.Screen name="Home1" component={HomeScreen} />
        <Tab.Screen name="Settings1" component={SettingsScreen} />
        <Tab.Screen name="Home2" component={HomeScreen} />
        <Tab.Screen name="Settings2" component={SettingsScreen} />
      </Tab.Navigator>
    </View>
  )
}

参考链接:

https://chat.xutongbao.top/

https://www.cnblogs.com/tengyuxin/p/13263143.html

https://reactnavigation.org/docs/material-top-tab-navigator/

相关推荐
羊吖19 小时前
Vue3 + Electron 实现纯本地人脸识别登录一体机(离线可用、无云端、带页面跳转)
前端·javascript·electron
卸载引擎19 小时前
NTP 授时(Network Time Protocol)核心解读,工控机electron程序自动联网授时案例
前端·javascript·electron
小奶包他干奶奶19 小时前
什么是原型链(Prototype Chain)?proto和prototype的关系与区别是什么?
前端·javascript
studyForMokey19 小时前
【跨端技术ReactNative】JavaScript学习
android·javascript·学习·react native·react.js
大雷神19 小时前
HarmonyOS APP<玩转React>开源教程十:组件化开发概述
前端·react.js·开源·harmonyos
我命由我1234519 小时前
Element Plus - 在 el-select 的每个选项右侧添加按钮
前端·javascript·vue.js·前端框架·ecmascript·html5·js
codingWhat20 小时前
Electron 入门实战:用一个加法计算器吃透 Electron 核心概念
前端·javascript·electron
Easonmax20 小时前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-pager-view — 流畅的页面滑动体验
react native·react.js·harmonyos
张一凡9320 小时前
easy-model 在任务管理应用中的实际应用
前端·react.js
TechFind20 小时前
AI Agent 开发完整教程:从零到上线的实战指南
java·javascript