react-native 加载动画 loading效果

朴灿烈づ我的快乐病毒、 2022-08-29 15:53 576阅读 0赞

react-native loading动画(加载动画)

      1. 组件代码(demo.js)
      1. 调用
      1. FAQ

在这里插入图片描述

1. 组件代码(demo.js)

  1. import Taro, { PureComponent } from '@tarojs/taro'
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. ActivityIndicator,
  7. } from 'react-native';
  8. export default class ActivityIndicatorDemo extends PureComponent {
  9. render() {
  10. const { loadingStatus = true, loadingColor = '#6495ED' } = this.props;
  11. const styles = StyleSheet.create({
  12. container: {
  13. flex: 1,
  14. justifyContent: "center"
  15. },
  16. horizontal: {
  17. flexDirection: "row",
  18. justifyContent: "space-around",
  19. padding: 10
  20. }
  21. });
  22. return (
  23. <View style={[styles.container, styles.horizontal]}>
  24. <ActivityIndicator size="large" color={loadingColor} animating={loadingStatus} />
  25. </View>
  26. );
  27. }
  28. }
  • 目前两个值为动态传入:
  • loadingColor => 动画颜色
  • animating => 动画关闭或开启
  • size也可灵活配置,由外部传入

2. 调用

  1. // 引入此组件
  2. import ActivityIndicatorDemo from './demo.js'
  3. // state里的值
  4. this.state = {
  5. red: red,
  6. animating: true
  7. }
  8. // 调用
  9. <ActivityIndicatorDemo
  10. loadingColor = {red}
  11. animating = {animating}
  12. ><ActivityIndicatorDemo />

3. FAQ

  • 注意reactNative的版本(0.5以下不支持 ActivityIndicator)
  • 注意传值

1. 希望本文能对大家有所帮助,如有错误,敬请指出

2. 原创不易,还请各位客官动动发财的小手支持一波(关注、评论、点赞、收藏)
3. 拜谢各位!后续将继续奉献优质好文
4. 如果存在疑问,可以私信我

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,576人围观)

还没有评论,来说两句吧...

相关阅读

    相关 cocos2d-x - loading动画

    相信大家在玩游戏的过程中都会遇到一个loading的界面,loading界面的作用主要是为了加载游戏中需要用到的资源。在比较大型的游戏中,资源通常会占用很大的空间,如果不做一个