Skip to content

Loadmore 加载更多

信息流列表底部加载状态指示器组件,支持 more(可加载)、loading(加载中)与 nomore(全部加载完成)三种核心状态,提供极奢微分割线与 6 种 Loading 动画形态。


代码示例

1. 基础用法 (Basic Usage)

直接绑定 :loading:finished 响应式变量,自动推导加载状态。

vue
<template>
  <view class="list">
    <view v-for="item in list" :key="item.id" class="item">
      {{ item.title }}
    </view>

    <!-- 加载更多指示器 -->
    <mu-loadmore
      :loading="isLoading"
      :finished="isFinished"
      finished-text="— 已加载完全部内容 —"
      @click="onLoadMore"
    />
  </view>
</template>

<script setup>
import { ref } from 'vue'

const isLoading = ref(false)
const isFinished = ref(false)
const list = ref([{ id: 1, title: '数据项 1' }])

function onLoadMore() {
  if (isLoading.value || isFinished.value) return
  isLoading.value = true
  setTimeout(() => {
    list.value.push({ id: list.value.length + 1, title: `数据项 ${list.value.length + 1}` })
    isLoading.value = false
  }, 1000)
}
</script>

2. 核心状态展示 (3 Status States)

直接通过 status 属性配置状态 (more | loading | nomore)。

vue
<template>
  <!-- 1. 待加载状态 -->
  <mu-loadmore status="more" text-more="点击加载更多" />

  <!-- 2. 加载中状态 -->
  <mu-loadmore status="loading" text-loading="正在拉取更多数据..." />

  <!-- 3. 已完全加载状态 -->
  <mu-loadmore status="nomore" finished-text="— 没有更多了 —" />
</template>

3. 自定义动画形态与色彩 (Icon Types & Colors)

通过 iconType 选择 6 种 Loading 动画(ring | spinner | bento | orbit | wave | dots),并可使用 color 设置文本与图标主题色彩。

vue
<template>
  <mu-loadmore status="loading" icon-type="orbit" color="#3B82F6" text-loading="Orbit 流光加载" />
  <mu-loadmore status="loading" icon-type="bento" color="#10B981" text-loading="Bento 冰晶加载" />
</template>

API 属性说明 (Props)

参数名说明类型可选值默认值
status显式状态(优先级高)String'more' | 'loading' | 'nomore''more'
loading是否处于加载中状态Booleantrue | falsefalse
finished是否已全部加载完成Booleantrue | falsefalse
textMore / moreText待加载状态文案String-'加载更多'
textLoading / loadingText加载中状态文案String-'正在加载...'
textNomore / finishedText加载完全状态文案String-'没有更多了'
iconType加载动画形态Stringring | spinner | bento | orbit | wave | dots'ring'
iconSize加载图标尺寸 (rpx)Number | String-28
color主主题色彩(文本与 Loading 图标)String-'' (自适应暗黑模式)
linenomore 状态时是否显示两侧极奢微分割线Booleantrue | falsetrue
lineColor分割线自定义颜色String-''

事件说明 (Events)

事件名说明回调参数
click当 status 为 'more' 且用户点击该组件时触发(常用于手动触发下一页)(event: MouseEvent)

基于 MIT 协议开源发行

H5 模拟器 (loadmore)☀️🔄