ts-basic-components-progress.md 4.7 KB
Newer Older
Z
zengyawen 已提交
1 2
# Progress

T
third  
tianyu 已提交
3
进度条组件,用于显示内容加载或操作处理等进度。
Z
zengyawen 已提交
4

G
gmy 已提交
5 6 7
>  **说明:**
>
>  该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
Z
zengyawen 已提交
8

Z
zengyawen 已提交
9 10

## 子组件
Z
zengyawen 已提交
11 12 13



Z
zengyawen 已提交
14 15 16

## 接口说明

K
kangchongtao 已提交
17
Progress(options: {value: number, total?: number, type?: ProgressType})
Z
zengyawen 已提交
18 19 20

创建进度组件,用于显示内容加载或操作处理进度。

G
gmy 已提交
21
**参数:**
Z
zengyawen 已提交
22

G
gmy 已提交
23 24 25 26
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| value | number | 是 | 指定当前进度值。 |
| total | number | 否 | 指定进度总长。<br/>默认值:100 |
T
third  
tianyu 已提交
27 28
| type<sup>8+</sup> | ProgressType | 否 | 指定进度条样式。<br/>默认值:ProgressType.Linear |
| style<sup>deprecated</sup> | ProgressStyle | 否 | 指定进度条类型。<br/>该参数从API Version8开始废弃,建议使用type替代。<br/>默认值:ProgressStyle.Linear |
Z
zengyawen 已提交
29

G
gmy 已提交
30
## ProgressType枚举说明
Z
zengyawen 已提交
31

G
gmy 已提交
32 33
| 名称 | 描述 |
| -------- | -------- |
T
third  
tianyu 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Linear | 线性样式。 |
| Ring<sup>8+</sup> | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 |
| Eclipse<sup>8+</sup> | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 |
| ScaleRing<sup>8+</sup> | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 |
| Capsule<sup>8+</sup> | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 |

##  ProgressStyle枚举说明 

| 名称      | 描述                                                         |
| --------- | ------------------------------------------------------------ |
| Linear    | 线性样式。                                                   |
| Ring      | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。             |
| Eclipse   | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 |
| ScaleRing | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。         |
| Capsule   | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 |
Z
zengyawen 已提交
49 50 51

## 属性

G
gmy 已提交
52 53 54
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| value | number | 设置当前进度值。 |
H
HelloCrease 已提交
55 56
| color | [ResourceColor](ts-types.md) | 设置进度条前景色。 |
| style<sup>8+</sup> | {<br/>strokeWidth?:&nbsp;[Length](ts-types.md#length),<br/>scaleCount?:&nbsp;number,<br/>scaleWidth?:&nbsp;[Length](ts-types.md#length)<br/>} | 定义组件的样式。<br/>-&nbsp;strokeWidth:&nbsp;设置进度条宽度。<br/>-&nbsp;scaleCount:&nbsp;设置环形进度条总刻度数。<br/>-&nbsp;scaleWidth:&nbsp;设置环形进度条刻度粗细,刻度粗细大于进度条宽度时,为系统默认粗细。 |
Z
zengyawen 已提交
57 58 59


## 示例
Z
zengyawen 已提交
60

H
geshi  
HelloCrease 已提交
61 62
```ts
// xxx.ets
Z
zengyawen 已提交
63 64 65 66
@Entry
@Component
struct ProgressExample {
  build() {
Z
zengyawen 已提交
67
    Column({ space: 15 }) {
Z
zengyawen 已提交
68
      Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
Y
yaoyuchi 已提交
69 70
      Progress({ value: 10, type: ProgressType.Linear }).width(200)
      Progress({ value: 20, total: 150, type: ProgressType.Linear }).color(Color.Grey).value(50).width(200)
Z
zengyawen 已提交
71 72 73

      Text('Eclipse Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
Y
yaoyuchi 已提交
74 75
        Progress({ value: 10, type: ProgressType.Eclipse }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.Eclipse }).color(Color.Grey).value(50).width(100)
Z
zengyawen 已提交
76 77 78 79
      }

      Text('ScaleRing Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
Y
yaoyuchi 已提交
80 81
        Progress({ value: 10, type: ProgressType.ScaleRing }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.ScaleRing })
Z
zengyawen 已提交
82
          .color(Color.Grey).value(50).width(100)
Y
yaoyuchi 已提交
83
          .style({ strokeWidth: 15, scaleCount: 15, scaleWidth: 5 })
Z
zengyawen 已提交
84 85 86 87
      }

      Text('Ring Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
Y
yaoyuchi 已提交
88 89
        Progress({ value: 10, type: ProgressType.Ring }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.Ring })
Z
zengyawen 已提交
90
          .color(Color.Grey).value(50).width(100)
Y
yaoyuchi 已提交
91
          .style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 20 })
Z
zengyawen 已提交
92 93 94 95
      }

      Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
T
tianyu 已提交
96
        Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50)
G
gmy 已提交
97 98 99 100 101
        Progress({ value: 20, total: 150, type: ProgressType.Capsule })
          .color(Color.Grey)
          .value(50)
          .width(100)
          .height(50)
Z
zengyawen 已提交
102 103
      }
    }.width('100%').margin({ top: 30 })
Z
zengyawen 已提交
104 105 106 107
  }
}
```

Z
zengyawen 已提交
108
![zh-cn_image_0000001198839004](figures/zh-cn_image_0000001198839004.gif)