Progress 进度条

概述

展示操作或任务的当前进度,比如上传文件。

使用指南

在 .json 中引入组件

  1. "usingComponents": {
  2. "i-progress": "../../dist/progress/index"
  3. }

示例

  1. <view class="progress-item">
  2. <i-progress percent="25"></i-progress>
  3. <i-progress percent="45" status="active"></i-progress>
  4. <i-progress percent="65" status="wrong"></i-progress>
  5. <i-progress percent="100" status="success"></i-progress>
  6. <i-progress percent="25" hide-info></i-progress>
  7. </view>
  8. <view class="progress-item">
  9. <i-progress percent="{{ percent }}" status="{{ status }}"></i-progress>
  10. <i-button bindclick="handleAdd" type="ghost">增加</i-button>
  11. <i-button bindclick="handleReduce" type="ghost">减少</i-button>
  12. </view>
  1. Page({
  2. data: {
  3. percent: 0,
  4. status: 'normal'
  5. },
  6. handleAdd () {
  7. if (this.data.percent === 100) return;
  8. this.setData({
  9. percent: this.data.percent + 10
  10. });
  11. if (this.data.percent === 100) {
  12. this.setData({
  13. status: 'success'
  14. });
  15. }
  16. },
  17. handleReduce () {
  18. if (this.data.percent === 0) return;
  19. this.setData({
  20. percent: this.data.percent - 10,
  21. status: 'normal'
  22. });
  23. }
  24. });

API

Progress properties

属性说明类型默认值
i-class自定义 class 类名String-
percent百分比Number0
status状态,可选值为 normal、active、wrong、successStringnormal
stroke-width进度条的线宽,单位 pxNumber10
hide-info隐藏数值或状态图标Booleanfalse