更新记录
1.0.1(2026-07-28) 下载此版本
- 修复封装为 uni_modules 后圆环不显示的问题
- 移除
#ifdef条件编译,H5 / 小程序统一使用 CSS 圆环
平台兼容性
uni-app(4.02)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | √ | √ | √ |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ |
uni-app x(4.0)
| Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|
| - | - | - | - | - | - |
nny-charge-ring 充电圆形进度条
充电场景圆形进度条组件,可实时跟随进度更新。
- H5 / 微信小程序:统一 CSS 双半圆方案(兼容性更好)
- 支持自定义颜色、尺寸、文案
- 支持默认插槽自定义中心内容
- easycom 自动引入,下载后即可使用
平台兼容
| H5 | 微信小程序 | App-vue | Vue2 | Vue3 |
|---|---|---|---|---|
| √ | √ | √ | √ | √ |
安装
- 通过插件市场导入到项目,或将
uni_modules/nny-charge-ring复制到你的项目 - 无需手动 import(uni_modules easycom 会自动注册)
基本用法
<template>
<view>
<nny-charge-ring :progress="progress" :charging="isCharging" />
<button @tap="start">开始充电</button>
</view>
</template>
<script>
export default {
data() {
return {
progress: 0,
isCharging: false,
timer: null
}
},
methods: {
start() {
if (this.isCharging) return
this.progress = 0
this.isCharging = true
this.timer = setInterval(() => {
if (this.progress >= 99) {
this.progress = 100
this.isCharging = false
clearInterval(this.timer)
return
}
this.progress += 1
}, 80)
}
}
}
</script>
自定义颜色 / 尺寸
<nny-charge-ring
:progress="60"
:charging="true"
:size="400"
active-color="#2563EB"
full-color="#16A34A"
text-color="#0F172A"
/>
自定义中心内容(插槽)
<nny-charge-ring :progress="progress" :charging="true">
<view class="custom">
<text>{{ progress }}%</text>
<text>自定义内容</text>
</view>
</nny-charge-ring>
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| progress | Number | 0 |
进度 0-100 |
| charging | Boolean | false |
是否充电中(影响状态文案与动效) |
| size | Number | 520 |
组件尺寸(rpx) |
| activeColor | String | #0891B2 |
充电中进度颜色 |
| fullColor | String | #22C55E |
充满进度颜色 |
| trackColor | String | rgba(8,145,178,0.14) |
轨道颜色 |
| textColor | String | #164E63 |
百分比文字颜色 |
| statusColor | String | #0E7490 |
状态文字颜色 |
| showIcon | Boolean | true |
显示电池图标 |
| showPercent | Boolean | true |
显示百分比 |
| showStatus | Boolean | true |
显示状态文案 |
| showDash | Boolean | true |
显示外圈虚线 |
| showGlow | Boolean | true |
显示光晕 |
| idleText | String | 待机 |
待机文案 |
| chargingText | String | 充电中 |
充电中文案 |
| fullText | String | 已充满 |
充满文案 |
| chargingIcon | String | 内置路径 | 充电中图标 |
| fullIcon | String | 内置路径 | 充满图标 |
Slot
| 名称 | 说明 |
|---|---|
| default | 自定义圆环中心内容(传入后替换默认图标/百分比/状态) |
注意事项
- 进度由外部传入并控制,组件本身不负责计时逻辑,便于接入真实电量数据
- 微信小程序请使用真机或开发者工具重新编译预览
- 自定义图标请放在项目可访问路径,并通过
chargingIcon/fullIcon传入
示例项目
本仓库 pages/index/index 为完整演示页,可直接运行查看效果。

收藏人数:
下载插件并导入HBuilderX
下载示例项目ZIP
赞赏(0)
下载 18
赞赏 1
下载 12465145
赞赏 1936
赞赏
京公网安备:11010802035340号