更新记录

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

安装

  1. 通过插件市场导入到项目,或将 uni_modules/nny-charge-ring 复制到你的项目
  2. 无需手动 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 自定义圆环中心内容(传入后替换默认图标/百分比/状态)

注意事项

  1. 进度由外部传入并控制,组件本身不负责计时逻辑,便于接入真实电量数据
  2. 微信小程序请使用真机或开发者工具重新编译预览
  3. 自定义图标请放在项目可访问路径,并通过 chargingIcon / fullIcon 传入

示例项目

本仓库 pages/index/index 为完整演示页,可直接运行查看效果。

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT License

Copyright (c) 2026

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

暂无用户评论。