微信小程序~上推加载更多组件

本组件使用的是Taro+React 实现的 ,具体代码如下

一共分为tsx和less文件

javascript 复制代码
//index.tsx
/** RefreshLoading
 * @description 上推加载更多组件
 * @param loading boolean
 * @param style
 * @returns
 */

import { View } from "@tarojs/components";
import React, { FC } from "react";
import styles from "./styles.module.less";

interface IProps {
  loading: boolean;
  style?: React.CSSProperties;
  hasMore?: boolean;
}

const RefreshLoading: FC<IProps> = ({
  loading = false,
  style = {},
  hasMore = true,
}) => {
  return (
    <View className={styles.wrap}>
      {loading ? (
        <View className={styles.refreshLoading} style={style}>
          <View className={styles.animate}>
            {[1, 2, 3].map((item) => (
              <View className={styles.point} key={item} />
            ))}
          </View>
          <View className={styles.text}>数据加载中</View>
        </View>
      ) : !hasMore ? (
        <View className={styles.hasMore}>没有更多了</View>
      ) : (
        <></>
      )}
    </View>
  );
};

export default RefreshLoading;
javascript 复制代码
//less文件
.wrap {
  padding: 0 0 10px 0;
}

.refreshLoading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;

  .animate {
    font-size: 0;
    .point {
      display: inline-block;
      width: 12 * 0.5px;
      height: 12 * 0.5px;
      margin-right: 4 * 0.5px;
      background: #00c8c8;
      border-radius: 50%;
      animation: load 0.65s ease infinite;

      &:last-child {
        margin-right: 0;
      }

      &:nth-of-type(1) {
        animation-delay: 0.13s;
      }

      &:nth-of-type(2) {
        animation-delay: 0.26s;
      }

      &:nth-of-type(3) {
        animation-delay: 0.39s;
      }
    }
  }

  .text {
    margin-left: 8px;
    color: #999;
    font-size: 12px;
  }
}

.hasMore {
  text-align: center;
  color: #999;
  font-size: 12px;
}

@keyframes load {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

具体使用如下

相关推荐
懂懂tty29 分钟前
React状态更新流程
前端·react.js
小码哥_常40 分钟前
告别繁琐!手把手教你封装超实用Android原生Adapter基类
前端
skywalk81631 小时前
pytest测试的时候这是什么意思?Migrating <class ‘kotti.resources.File‘>
前端·python
一只蝉nahc1 小时前
vue使用iframe内嵌unity模型,并且向模型传递信息,接受信息
前端·vue.js·unity
子兮曰2 小时前
Bun v1.3.12 深度解析:新特性、性能优化与实战指南
前端·typescript·bun
2401_885885043 小时前
易语言彩信接口怎么调用?E语言Post实现多媒体数据批量下发
前端
a1117763 小时前
Three.js 的前端 WebGL 页面合集(日本 开源项目)
前端·javascript·webgl
Kk.08023 小时前
项目《基于Linux下的mybash命令解释器》(一)
前端·javascript·算法
小李子呢02114 小时前
前端八股---闭包和作用域链
前端
IT_陈寒4 小时前
Redis的内存溢出坑把我整懵了,分享这个血泪教训
前端·人工智能·后端