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/

相关推荐
昇腾CANN8 小时前
TileLang-Ascend 算子性能优化方法与实操
开发语言·javascript·性能优化·昇腾·cann
老王以为8 小时前
为什么 React 和 Vue 不一样?
前端·vue.js·react.js
web打印社区8 小时前
2026最新Web静默打印解决方案,无插件无预览,完美替代Lodop
前端·javascript·vue.js·electron·pdf
蜡台8 小时前
H5使用Chrome 权限问题
前端·javascript·chrome
大貔貅喝啤酒9 小时前
接口测试_Postman(详细版)
javascript·测试工具·node.js·自动化·postman
小小码农Come on9 小时前
QML访问子项内容
前端·javascript·html
桜吹雪9 小时前
Langchain.js官方文档:构建具备按需加载技能的 SQL 助手
javascript·人工智能·node.js
一行代码一行诗++9 小时前
注释是什么和注释该怎么写(C语言)
java·前端·javascript
陈振wx:zchen20089 小时前
前端-面试题-JavaScript
javascript·前端面试题
幽络源小助理10 小时前
小六壬排盘工具源码 自适应双端 纯原生HTML+JS
前端·javascript·html