• React Native利用router-flux简单实现标签页切换


    第一步创建一个react native 项目,在创建好的的项目App.js中引入 router-flux

    App.js代码

    import React, {Component} from 'react';
    import {Platform, StyleSheet, Text, View,Image} from 'react-native';
    import {Scene,Router,Tabs} from "react-native-router-flux";
    import Information from "./app/first/Information";
    import Me from "./app/fourth/Me";
    import MailList from "./app/second/MailList";
    import Find from "./app/third/Find";
    
    
    type Props = {};
    export default class App extends Component<Props> {
        InformationIcon=({focused})=>{
            if(focused){
                return(
                    <Image style={{32,height:32}} source={require("./img/xinxi3.png")}/>
                )
            }else {
                return(
                    <Image style={{32,height:32}} source={require("./img/xinxi1.png")}/>
                )
            }
        }
        MailListIcon=({focused})=> {
            if (focused){
                return(
                    <Image style={{height: 30,  30}} source={require('./img/tongxunluZ.png')}/>
                )
            } else {
                return(
                    <Image style={{30,height:30}} source={require("./img/tongxunlu.png")}/>
                )
            }
        }
    
    
        MeIcon=({focused})=> {
            if (focused){
                return(
                    <Image style={{height: 30,  30}} source={require('./img/faxianZ.png')}/>
                )
            } else {
                return(
                    <Image style={{30,height:30}} source={require("./img/faxian.png")}/>
                )
            }
        }
        FindIcon=({focused})=> {
            if (focused){
                return(
                    <Image style={{height: 30,  30}} source={require('./img/woZ.png')}/>
                )
            } else {
                return(
                    <Image style={{30,height:30}} source={require("./img/wo.png")}/>
                )
            }
        }
      render() {
        return (
            <Router>
                <Scene  key="root" initial={true} tabBarPosition={"bottom"} >
                    <Tabs
                        key={"tabbar"}
                        swipeEnabled={true}
                        hideNavBar={true}
                        //隐藏标签栏
                        wrap={false}
                        showLable={false}
                        activeBackgroundColor={"white"}
                        inactiveBackgroundColor={"white"}
                        activeTintColor={"#46B11C"}
                        inactiveTintColor={"#9A9A9A"}
                        tabBarStyle={{height:65}}
                        labelStyle={{paddingBottom:0,fontSize:14}}
                    >
                        <Scene key={"Information"} component={Information} title="微信" icon={this.InformationIcon}/>
                        <Scene key={"MailList"} component={MailList}  title="通讯录" icon={this.MailListIcon}/>
                        <Scene key={"Find"} component={Find} title="发现" icon={this.MeIcon}/>
                        <Scene key={"Me"} component={Me} title="我"icon={this.FindIcon}/>
                    </Tabs>
                </Scene>
            </Router>
    
        );
      }
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#FFFFFF',
      },
      welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
      },
      instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
      },
    });
    View Code

    然后我是创建了一个app然后里面创建了四个文件夹,里面分别放了切换的四个页面

    总结:

    项目创建好有一个App.js ——》

    一个自己创建的app文件夹——》

    一个自己创建的img文件夹存放图片  ——》

    最后通过App.js引入进app文件中的代码

    模块很少,代码很少。

    效果图:

     源码:

    链接: https://pan.baidu.com/s/1jUdAZBOh2mkQO8TQxBGZ1Q

    提取码: vvtc 

  • 相关阅读:
    如果控制文件损坏那么如何恢复?恢复控制文件的方式有哪几种
    【OCP|OCM】Oracle培训考证系列
    【RMAN】Oracle中如何备份控制文件?备份控制文件的方式有哪几种?
    在高并发、高负载的情况下,如何给表添加字段并设置DEFAULT值?
    CentOS 7.1静默安装11.2.0.3 64位单机数据库软件
    造成错误“ORA-12547: TNS:lost contact”的常见原因有哪些?
    如何让oracle DB、监听和oem开机启动(dbstart)
    ipcs、ipcrm、sysresv、kernel.shmmax
    【DG】利用闪回数据库(flashback)修复Failover后的DG环境
    【BBED】BBED模拟并修复ORA-08102错误
  • 原文地址:https://www.cnblogs.com/zsylongtime/p/10237115.html
Copyright © 2020-2023  润新知