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

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

具体使用如下

相关推荐
xing251614 分钟前
pytest-html
前端·html·pytest
茂茂在长安24 分钟前
Linux 命令大全完整版(11)
java·linux·运维·服务器·前端·centos
知识分享小能手1 小时前
Html5学习教程,从入门到精通,HTML5 简介语法知识点及案例代码(1)
开发语言·前端·javascript·学习·前端框架·html·html5
IT、木易1 小时前
大白话React第二章深入理解阶段
前端·javascript·react.js
晚安7201 小时前
Ajax相关
前端·javascript·ajax
图书馆钉子户1 小时前
怎么使用ajax实现局部刷新
前端·ajax·okhttp
bin91531 小时前
DeepSeek 助力 Vue 开发:打造丝滑的单选按钮(Radio Button)
前端·javascript·vue.js·ecmascript·deepseek
qianmoQ1 小时前
第五章:工程化实践 - 第五节 - Tailwind CSS 常见问题解决方案
前端·css
那就可爱多一点点2 小时前
超高清大图渲染性能优化实战:从页面卡死到流畅加载
前端·javascript·性能优化
不能只会打代码3 小时前
六十天前端强化训练之第一天HTML5语义化标签深度解析与博客搭建实战
前端·html·html5