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/

相关推荐
无聊的老谢3 分钟前
Vue 3 + Leaflet 实现高性能 Web GIS 基站监控平台
前端·javascript·vue.js
之歆5 分钟前
Day23_Bootstrap 前端框架完全指南:从栅格系统到组件化开发
开发语言·前端·javascript·前端框架·bootstrap·ecmascript·less
前端 贾公子5 分钟前
3.响应式系统基础:从发布订阅模式的角度理解 Vue2 的数据响应式原理(上)
前端·javascript·vue.js
wordbaby9 小时前
React Native + RNOH:跨页面数据回传的最佳实践与避坑指南
前端·react native
GISer_Jing9 小时前
Three.js着色器编译机制深度解析
javascript·webgl·着色器
丷丩9 小时前
MapLibre GL JS第22课:查看本地GeoJSON
前端·javascript·map·mapbox·maplibre gl js
油炸自行车9 小时前
Claude Code 错误:API Error: 400 Failed to deserialize the JSON body into the
开发语言·javascript·json·trae·claude code·api error 400
丷丩13 小时前
MapLibre GL JS第19课:实时更新要素
前端·javascript·gis·map·mapbox·maplibre gl js
xiaohua0708day14 小时前
Lodash库
前端·javascript·vue.js
突然好热14 小时前
TS 调试技巧
前端·javascript·typescript