RN 的scrollable-tab-view控件(同一页面选择切换)
来源:互联网 发布:瑶知天上桂花孤的意思 编辑:程序博客网 时间:2024/06/07 01:33
一. 基础选项卡
1.引入依赖:
在终端引入依赖: npm install react-native-scrollable-tab-view –save
2. 在 index.ios.js 文件中
import React from 'react';import { AppRegistry, Text, Button, View,} from 'react-native';var ScrollableTabView = require('react-native-scrollable-tab-view'); //引入控件,并在终端添加依赖 npm install react-native-scrollable-tab-view --savevar MoveList = require("./movieListView"); //也可以引入一个页面使用var MyList = require("./myListView"); //也可以引入一个页面使用var Movie = require("./movieList"); //也可以引入一个页面使用var App = React.createClass({ render() { return ( <ScrollableTabView> <MoveList tabLabel="React" /> <Movie tabLabel="Flow" /> <MyList tabLabel="Jest" /> </ScrollableTabView> ); }});AppRegistry.registerComponent('HelloReactNative', () => App);
二. 具有导航功能的选项卡
1.引入依赖
在终端引入依赖: npm install react-native-scrollable-tab-view –save
在终端引入依赖: npm install react-navigation –save
2. 在 index.ios.js 文件中
import React from 'react';import { AppRegistry, Text, Button, View,} from 'react-native';import { StackNavigator } from 'react-navigation';var ScrollableTabView = require('react-native-scrollable-tab-view'); //引入控件,并在终端添加依赖 npm install react-native-scrollable-tab-view --savevar MoveList = require("./movieListView"); //也可以引入一个页面使用var MyList = require("./myListView"); //也可以引入一个页面使用var Movie = require("./movieList"); //也可以引入一个页面使用var App = React.createClass({ render() { return ( <ScrollableTabView tabBarPosition='bottom' > {/*tabBarPosition //可以设置顶部或者底部选项*/} {/*{...this.props} //指定导航页*/} <RecentChatsScreen tabLabel="React" {...this.props} /> <AllContactsScreen tabLabel="Flow" {...this.props} /> </ScrollableTabView> ); }});class ChatScreen extends React.Component { // Nav options can be defined as a function of the screen's props: static navigationOptions = ({ navigation }) => ({ title: `Chat with ${navigation.state.params.user}`, }); render() { // The screen's current route is passed in to `props.navigation.state`: const { params } = this.props.navigation.state; return ( <View> <Text>Chat with {params.user}</Text> </View> ); }}class RecentChatsScreen extends React.Component { render() { const { navigate } = this.props.navigation; return ( <View> <Text>List of recent chats</Text> <Button onPress={() => navigate('Chat', {user: 'Lucy'})} //Passing params title="Chat with Lucy" /> </View> ); }}class AllContactsScreen extends React.Component { render() { const { navigate } = this.props.navigation; return ( <View> <Text>List of all contacts</Text> <Button //跳转 onPress={() => navigate('Chat', {user: 'Jane'})} //Passing params title="Chat with Jane" /> </View> ); }}App.navigationOptions = { title: 'My Chats',};const SimpleAppReactNavigation = StackNavigator({ Home: { screen: App }, //第一栈 Chat: { screen: ChatScreen }, //第二栈});AppRegistry.registerComponent('HelloReactNative', () => SimpleAppReactNavigation);
阅读全文
0 0
- RN 的scrollable-tab-view控件(同一页面选择切换)
- 【React Native开发】- scrollable-tab-view的使用
- react-native-scrollable-tab-view的版本坑
- ReactNative组件-react-native-scrollable-tab-view
- React:react-native-scrollable-tab-view
- react-native-scrollable-tab-view 使用总结
- react-native-scrollable-tab-view详解
- 选项卡react-native-scrollable-tab-view
- 利用命令切换CTabCtrl控件的Tab页面
- 同一页面tab切换对应显示内容分页实现
- Tab键、方向键切换页面控件焦点
- 开源项目react-native-scrollable-tab-view的基本使用方法
- react-native-scrollable-tab-view 嵌套react-native-swiper 引发的 bug
- 基于RN实现顶部tab导航切换
- 选项卡react-native-scrollable-tab-view(入门篇)
- 选项卡react-native-scrollable-tab-view(进阶篇)
- [React Native]react-native-scrollable-tab-view(入门篇)
- [React Native]react-native-scrollable-tab-view(进阶篇)
- JobService和JobScheduler机制在Android5.0以上保活
- 漂亮简单js分页实现
- JAVAweb开发中 新建子包不见了 【问题解决】
- Springboot使用定时任务,Spring Schedule
- 最简单的基于FFmpeg的libswscale的示例附件:测试图片生成工具
- RN 的scrollable-tab-view控件(同一页面选择切换)
- docker技术学习-安装和入门基本操作
- LeetCode-506. Relative Ranks (Java)
- setDoOutput()和setDoInput()
- 多表查询
- 最简单的基于FFmpeg的libswscale的示例(YUV转RGB)
- idea的使用
- DRUID- 查询遇到的坑
- vim按键整理