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

本组件使用的是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;
  }
}

具体使用如下

相关推荐
晚霞的不甘8 分钟前
Flutter for OpenHarmony《淘淘购物》主页点击跳转功能详解:从 UI 响应到页面导航的完整实现
前端·flutter·ui·搜索引擎·前端框架·交互
cooldream20099 分钟前
前端技术架构详解:Vue 3 + TypeScript + Vite 在具身 AI 系统中的实践
前端·架构·typescript
迟_31 分钟前
CSS-实现图片靠右
前端·css
weixin_3954489134 分钟前
下位机&yolov11输出
java·服务器·前端
秋秋秋秋秋雨38 分钟前
基于若依的vue3+springboot3基础架构项目,前端优化
前端
Dragon Wu40 分钟前
Web前端 认证token的安全存储策略
前端·javascript·安全·react.js·前端框架
橙露42 分钟前
各类 Shell 优劣势深度解析与实战选型指南
前端·chrome
广州华水科技1 小时前
单北斗GNSS在变形监测中的应用与发展探讨
前端
克里斯蒂亚诺更新1 小时前
vue2 单文件组件加入浏览器的title和ico的方法
前端·javascript·html
芝芝葡萄1 小时前
VsCode中使用Codex
前端·ide·vscode·编辑器·ai编程