Skip to content

Progress 进度条

介绍

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

引入

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

代码演示

基础用法

基础用法

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

进度内显示百分比

进度内显示百分比

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

自定义样式

自定义样式

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State 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
@Component
struct DemoPage {
  @State value: number = 50
  build() {
    IBestProgress({
      value: this.value,
      inactive: true
    })
  }
}

不确定进度

不确定进度

点我查看代码
ts
@Entry
@Component
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-

Events

事件名说明回调参数
onBarClick点击通知栏回调-
onClose点击右侧关闭图标回调-
onTextClick垂直滚动时,点击文字回调index: number