Skip to content

LoadingPopup 加载弹窗 v0.0.17+

19:21

u-loading-popup 是 uView Pro 提供的弹窗式加载动画组件,常用于页面或局部异步加载、数据请求等待等场景。相比普通的 u-loading,它支持遮罩、内容插槽、自动关闭等高级功能。

平台差异说明

AppH5微信小程序支付宝小程序百度小程序头条小程序QQ小程序

基本使用

通过 v-model 实现弹窗的双向绑定显示,mode 设定动画类型(circle 圆圈、flower 花朵),可自定义内容。

html
<template>
  <u-loading-popup v-model="show" mode="circle" text="加载中..." />
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  const show = ref(true)
</script>

方向

可通过 direction 属性设置内容方向,可选值有 vertical(垂直)和 horizontal(水平)。

html
<template>
  <u-loading-popup
    v-model="show"
    text="正在加载,请稍候..."
    :direction="direction"
  />
</template>
<script setup lang="ts">
  import { ref } from 'vue'
  const show = ref(true)

  const direction = ref<'vertical' | 'horizontal'>('vertical')
</script>

动画颜色与尺寸

  • color 设置动画颜色(仅 mode=circle 有效)。
  • size 设置动画尺寸,单位 rpx。
html
<u-loading-popup v-model="show" color="#2979ff" size="40" />

自动关闭与遮罩交互

  • duration 设置自动关闭时间(ms),默认(设置为 0)表示不自动关闭。
  • cancelTime 允许点击遮罩关闭的最短时间(ms),默认 10000。
    • 遮罩层点击在 cancelTime 毫秒后可关闭弹窗,触发 cancel 事件。
html
<u-loading-popup v-model="show" :duration="2000" :cancelTime="5000" />

事件

  • @cancel 点击遮罩关闭时触发。
html
<template>
  <u-loading-popup v-model="show" @cancel="handleCancel" />
</template>
<script setup lang="ts">
  import { ref } from 'vue'
  const show = ref(true)

  function handleCancel() {
    console.log('cancel')
  }
</script>

API

Props

参数说明类型默认值可选值
v-model弹窗显示的双向绑定Booleanfalsetrue/false
mode加载动画类型Stringcirclecircle/flower
text加载提示文字String--
direction内容方向Stringverticalvertical/horizontal
duration自动关闭时间(ms)Number0-
cancelTime允许点击遮罩关闭的最短时间Number10000-
color动画颜色String#c7c7c7-
size加载动画尺寸(rpx)String/Number48-

Events

事件名说明回调参数
cancel点击遮罩关闭时触发-

更多用法请参考组件源码和实际业务场景。