Skip to content

Progress 进度条

介绍

用于展示操作的当前进度。

引入

ts
import { IBestProgress } from "@ibestservices/ibest-ui-v2";

代码演示

基础用法

基础用法

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 50
  build() {
    Column(){
      IBestProgress({
        value: this.value!!
      })
    }
  }
}

进度内显示百分比

进度内显示百分比

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 50
  build() {
    Column(){
      IBestProgress({
        value: this.value!!,
        lineWidth: 18,
        textInside: true
      })
    }
  }
}

自定义样式

自定义样式

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 50
  format(value: number){
		return value < 100 ? `${value}%` : 'Full'
	}
  build() {
    Column({space: 16}){
      IBestProgress({
        value: this.value!!,
        color: "#ee0a24"
      })
      IBestProgress({
        value: this.value!!,
        linearGradientColor:{
          angle: 90,
          colors: [['#be99ff', 0], ['#7232dd', 1]]
        },
        format: (value: number): string => this.format(value)
      })
    }
  }
}

置灰

置灰

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 50
  build() {
    Column(){
      IBestProgress({
        value: this.value!!,
        inactive: true
      })
    }
  }
}

不确定进度

不确定进度

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  build() {
    Column({space: 16}){
      IBestProgress({
        value: 50,
        indeterminate: true
      })
      IBestProgress({
        value: 100,
        indeterminate: true,
        duration: 1,
        color: "#DB3131"
      })
    }
  }
}

API

@Props

参数说明类型默认值
value进度值number0
lineWidth进度条粗细string | number4
color进度条颜色ResourceColor#3D8AF2
linearGradientColor进度条渐变色LinearGradient-
bgColor进度条背景色ResourceColor#ebedf0
showText是否显示进度条文字booleantrue
textInside文字显示在进度条内booleanfalse
textColor文本颜色ResourceColor#323233
textFontSize左侧图标颜色string | number16
inactive文本颜色booleanfalse
indeterminate不确定进度booleanfalse
duration不确定进度时动画时长 单位秒number3
format格式化文本函数(value: number) => string-
target目标值number100

Events

事件名说明回调参数
onReachTarget到达目标值触发-