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

本组件使用的是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 分钟前
JavaScript 一些小特性:让你的代码更优雅高效
前端·javascript·架构
草帽lufei9 分钟前
高强度SOLO真实业务项目
前端·ai编程·trae
1024肥宅9 分钟前
告别异地登录告警!用 GitHub Self-Hosted Runner 打造“零打扰”全栈自动化部署
前端·后端·github
GDAL12 分钟前
CSS重置样式表(Reset CSS
前端·css
SpringLament14 分钟前
TanStack Virtual 源码解析:定高/不定高虚拟列表实现原理以及框架无关设计
前端·javascript
猪猪拆迁队15 分钟前
高性能 Package构建系统设计与实现
前端·后端·node.js
UIUV18 分钟前
JavaScript中instanceof运算符的原理与实现
前端·javascript·代码规范
前端fighter20 分钟前
全栈项目:闲置二手交易系统(一)
前端·vue.js·后端
飞行增长手记25 分钟前
IP协议从跨境到物联网的场景化应用
服务器·前端·网络·安全
我叫张小白。27 分钟前
Vue3 插槽:组件内容分发的灵活机制
前端·javascript·vue.js·前端框架·vue3