当前位置:首页 > uni-app

uniapp圆形加载

2026-02-06 00:16:31uni-app

uniapp 圆形加载实现方法

使用内置组件实现

uniapp提供了progress组件,可以通过设置stroke-widthcolor属性实现圆形加载效果。

<progress 
  percent="50" 
  stroke-width="10" 
  activeColor="#4cd964" 
  backgroundColor="#e5e5e5" 
  active
></progress>

使用CSS自定义样式

通过CSS可以实现更灵活的圆形加载动画效果。

<template>
  <view class="circle-progress">
    <view class="progress-bar"></view>
  </view>
</template>

<style>
.circle-progress {
  width: 100px;
  height: 100px;
  position: relative;
}

.progress-bar {
  width: 100%;
  height: 100%;
  border: 8px solid #f3f3f3;
  border-top: 8px solid #3498db;
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style>

使用第三方组件库

uniapp生态中有多个UI组件库提供圆形加载组件,如uView、ColorUI等。

<template>
  <u-circle-progress 
    :percent="70" 
    :width="150" 
    :border-width="12" 
    active-color="#2979ff"
  ></u-circle-progress>
</template>

SVG实现方案

使用SVG可以创建更精细的圆形进度条,支持渐变等效果。

<template>
  <view>
    <svg width="100" height="100" viewBox="0 0 100 100">
      <circle 
        cx="50" 
        cy="50" 
        r="45" 
        fill="none" 
        stroke="#e5e5e5" 
        stroke-width="10"
      />
      <circle 
        cx="50" 
        cy="50" 
        r="45" 
        fill="none" 
        stroke="#4cd964" 
        stroke-width="10" 
        stroke-dasharray="283" 
        stroke-dashoffset="141.5"
      />
    </svg>
  </view>
</template>

注意事项

  • 小程序平台对CSS动画支持有限,需测试兼容性
  • 使用第三方组件时需先安装对应库
  • 性能敏感场景建议使用原生组件而非CSS动画
  • 动态修改进度时可能需要添加过渡效果提升用户体验

uniapp圆形加载

标签: 圆形加载
分享给朋友:

相关文章

react如何加载网页

react如何加载网页

使用 React 加载网页的方法 通过 iframe 嵌入网页 在 React 组件中,可以通过 iframe 标签直接加载外部网页。这种方式简单直接,适合嵌入第三方页面或静态内容。 imp…

jquery页面加载

jquery页面加载

jQuery 页面加载事件 在 jQuery 中,页面加载事件通常通过 $(document).ready() 或简写的 $() 来实现。这种方式确保代码在 DOM 完全加载后执行,但无需等待图片等资…

vue实现图片加载

vue实现图片加载

Vue 实现图片加载的方法 在 Vue 中实现图片加载可以通过多种方式,以下是一些常见的方法: 使用 v-bind 绑定图片路径 通过 v-bind 动态绑定图片路径,可以灵活地加载本地或远程图片…

vue实现触底加载

vue实现触底加载

触底加载的实现方法 在Vue中实现触底加载功能,可以通过监听滚动事件或使用Intersection Observer API来实现。以下是两种常见的方法: 监听滚动事件 在组件中监听滚动事件,…

vue实现滑动加载

vue实现滑动加载

滑动加载的实现思路 滑动加载通常通过监听滚动事件,判断是否滚动到页面底部来触发数据加载。Vue中可以通过结合v-for、@scroll事件和计算属性实现。 基础实现方法 监听滚动事件 在包含滚动区…

js实现图片加载

js实现图片加载

使用Image对象加载图片 通过JavaScript的Image对象可以动态加载图片,适用于需要预加载或动态插入图片的场景。 const img = new Image(); img.src…