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/

相关推荐
じ☆ve 清风°4 分钟前
JavaScript 原型与原型链:深入理解 __proto__ 和 prototype 的由来与关系
开发语言·javascript·原型模式
哼唧唧_4 小时前
React Native开发鸿蒙运动健康类应用的项目实践记录
react native·harmonyos·harmony os5·运动健康
_r0bin_5 小时前
前端面试准备-7
开发语言·前端·javascript·fetch·跨域·class
IT瘾君5 小时前
JavaWeb:前端工程化-Vue
前端·javascript·vue.js
zhang98800005 小时前
JavaScript 核心原理深度解析-不停留于表面的VUE等的使用!
开发语言·javascript·vue.js
Aphasia3117 小时前
模式验证库——zod
前端·react.js
拉不动的猪8 小时前
都25年啦,还有谁分不清双向绑定原理,响应式原理、v-model实现原理
前端·javascript·vue.js
狂炫一碗大米饭8 小时前
一文打通TypeScript 泛型
前端·javascript·typescript
tingkeiii9 小时前
【react+antd+vite】优雅的引入svg和阿里巴巴图标
前端·react.js·前端框架
exploration-earth11 小时前
本地优先的状态管理与工具选型策略
开发语言·前端·javascript