react-native 加载动画 loading效果

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


在这里插入图片描述

1. 组件代码(demo.js)

import Taro, { PureComponent } from '@tarojs/taro'
import {
    StyleSheet,
    View,
    Text,
    ActivityIndicator,
} from 'react-native';
export default class ActivityIndicatorDemo extends PureComponent {
    render() {
        const { loadingStatus = true, loadingColor = '#6495ED' } = this.props;
        const styles = StyleSheet.create({
            container: {
                flex: 1,
                justifyContent: "center"
            },
            horizontal: {
                flexDirection: "row",
                justifyContent: "space-around",
                padding: 10
            }
        });
        return (
            <View style={[styles.container, styles.horizontal]}>
                <ActivityIndicator size="large" color={loadingColor} animating={loadingStatus} />
            </View>
        );
    }
}
  • 目前两个值为动态传入:
  • loadingColor => 动画颜色
  • animating => 动画关闭或开启
  • size也可灵活配置,由外部传入

2. 调用

// 引入此组件
import ActivityIndicatorDemo from './demo.js'
// state里的值
this.state = {
	red: red,
	animating: true
}
// 调用
<ActivityIndicatorDemo
loadingColor  = {red}
animating = {animating}
><ActivityIndicatorDemo />

3. FAQ

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

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

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

在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

欧阳呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值