React Native多图层View,实现empty,content,error,loading等界面无缝跳转
来源:互联网 发布:阿里云怎么代理加盟 编辑:程序博客网 时间:2024/06/06 18:07
(1)概述
这是我在github上开源的第二个项目,接触react native以来,在使用的过程中,由于产品的需求,自己封装了一个包含多图层的View,避免重复代码的产生。
react-native-multiview 点击这里到github,先上图
(2)用法
介绍一下用法:主要是提供一个状态,当然在state中管理这个状态,当然用mobx或者redux也可以!
1、首先,在命令行输入npm install -save react-native-multiview,引用该项目
2、在项目中添加引用
import {MultiView} from "react-native-multiview";import {PageStatus} from "react-native-multiview";其中MultiView的用法更React Native中View的用法一致,除此之外,还包含了其他的一些属性,请参照属性表,
PropsProp | Type | Optional | Default | Description------------------------ | ------ | -------- |---------------- | -----------status | string | Yes |PageStatus.content | status determines the current display of that page,
which includes{PageStatus.error,PageStatus.empty,
PageStatus.content,PageStatus.init,
PageStatus.loading}five status. onEmptyPress | func | Yes | | Click event of empty page buttononErrorPress | func | Yes | | Click event of error page buttonemptyImgSource | source | Yes | | Image of empty page showerrorImgSource | source | Yes | | Image of error page showemptyText | string | Yes | "" | Text of empty page descerrorText | string | Yes | "" | Text of error page descemptyBtnText | string | Yes | "" | Text of empty page button,Display when it is not empty,
Default does not displayerrorBtnText | string | Yes | "" | Text of error page button,Display when it is not empty,
Default does not displayemptyTextStyle | style | Yes | | The style of empty page texterrorTextStyle | style | Yes | | The style of error page textemptyButtonStyle | style | Yes | | The style of empty page buttonerrorButtonStyle | style | Yes | | The style of error page buttonemptyBgColor | color | Yes | | The backgroundcolor of empty pageerrorBgColor | color | Yes | | The backgroundcolor of error pageinitHint | string | Yes | | Hint of init page ActivityIndicatorloadingHint | string | Yes | | Hint of loading page ActivityIndicatorinitHintStyle | style | Yes | | The style of init page initHintloadingHintStyle | style | Yes | | The style of loading page loadingHintinitIndicatorColor | color | Yes | | The color of init page ActivityIndicatorloadingIndicatorColor | color | Yes | | The color of loading page ActivityIndicatorinitContainerBgColor | color | Yes | | The backgroundcolor of init page ActivityIndicator containerinitContainerBgColor | color | Yes | | The backgroundcolor of loading page ActivityIndicator container3、在项目中使用multiview包裹当前的界面UI,
render() { let that = this; return ( <MultiView status={that.state.status} emptyBgColor="white" errorBgColor="white" emptyText="你还没有添加商品呦" errorText="网络错误"> <View style={styles.container}> ... </View> </MultiView> );
PageStatus一共有5种状态,
- PageStatus.init 一般是进入页面初始化的时候使用
- PageStstus.content 就是显示页面的内容
- PageStatus.empty 当页面接在为空,比如收藏夹或者商品列表为空的时候使用
- PageStatus.error 当网络错误或者页面加载失败的时候使用
- PageStatus.loading 当页面需要刷新的时候使用
当然,多图层中颜色,背景,icon和提示文字都可以进行定制,有什么建议和意见欢迎@
原创博客,欢迎转载!
阅读全文
0 0
- React Native多图层View,实现empty,content,error,loading等界面无缝跳转
- react-native统一入口界面,并实现页面的跳转
- React native 界面跳转原生Android界面
- react native 界面跳转与点击事件
- react-native 使用Navigation跳转界面
- Android 请求网络loading 结果显示error empty界面
- React-Native 原生跳转不同的RN界面的实现思路
- react-native实现的无缝轮播demo
- React-native页面跳转传值实现
- 无缝为Activity、Fragment、任何View设置加载(loading)、重试(retry)和无数据(empty)页面。
- 无缝为Activity、Fragment、任何View设置加载(loading)、重试(retry)和无数据(empty)页面
- React-Native 实现QQ登录界面
- React Native实现二维码管理界面
- React Native 学习笔记(九)--网络请求 & 界面跳转
- 关于React Native 跳转到原生页面界面详解
- (十二)React Native跳转到android原生界面Activity
- 点击Android按钮跳转到React-native指定界面
- React-Native 中 StackNavigator的跳转界面的使用
- 控制台调试android命令
- AtCoder Beginner Contest 070 Transit Tree Path(一道鸡贼的最短路径题)
- 接触qt来第一个坑:Could not create directory "E:\oysl\QT\Error in " Util.asciify("build-untitle
- 线段树(Segment Tree)简介
- Ubuntu14.04kylin下PCL安装及环境配置
- React Native多图层View,实现empty,content,error,loading等界面无缝跳转
- angular4.0 HTTP初级,nodejs搭建服务器,并使用
- android studio 复制项目运行出现Application Installation Failed问题
- mysql 常用约束
- redis--内部结构--sds
- 文件写入对象
- TOMCAT原理详解及请求过程
- 使用pillow实现tensorflow中的一些图像增强函数(crop,contrast,flip,per_image_standardization)
- Java中Synchronized的用法