1# Progress 2 3进度条组件,用于显示内容加载或操作处理等进度。 4 5> **说明:** 6> 7> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 8 9 10## 子组件 11 12无 13 14 15## 接口 16 17Progress(options: {value: number, total?: number, type?: ProgressType}) 18 19创建进度组件,用于显示内容加载或操作处理进度。 20 21**参数:** 22 23| 参数名 | 参数类型 | 必填 | 参数描述 | 24| -------- | -------- | -------- | -------- | 25| value | number | 是 | 指定当前进度值。 | 26| total | number | 否 | 指定进度总长。<br/>默认值:100 | 27| type<sup>8+</sup> | [ProgressType](#progresstype枚举说明) | 否 | 指定进度条类型。<br/>默认值:ProgressType.Linear | 28| style<sup>deprecated</sup> | [ProgressStyle](#progressstyle枚举说明) | 否 | 指定进度条样式。<br/>该参数从API Version8开始废弃,建议使用type替代。<br/>默认值:ProgressStyle.Linear | 29 30## ProgressType枚举说明 31 32| 名称 | 描述 | 33| ---------------------- | ---------------------------------------- | 34| Linear | 线性样式。 | 35| Ring<sup>8+</sup> | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 | 36| Eclipse | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 | 37| ScaleRing<sup>8+</sup> | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 | 38| Capsule<sup>8+</sup> | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 | 39 40## ProgressStyle枚举说明 41 42| 名称 | 描述 | 43| ---------------------- | ------------------------------------------------------------ | 44| Linear | 线性样式。 | 45| Ring | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 | 46| Eclipse | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 | 47| ScaleRing | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 | 48| Capsule | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 | 49 50## 属性 51 52| 名称 | 参数类型 | 描述 | 53| -------- | -------- | -------- | 54| value | number | 设置当前进度值。 | 55| color | [ResourceColor](ts-types.md#resourcecolor) | 设置进度条前景色。 | 56| style<sup>8+</sup> | {<br/>strokeWidth?: [Length](ts-types.md#length),<br/>scaleCount?: number,<br/>scaleWidth?: [Length](ts-types.md#length)<br/>} | 定义组件的样式。<br/>- strokeWidth: 设置进度条宽度。<br/>- scaleCount: 设置环形进度条总刻度数。<br/>- scaleWidth: 设置环形进度条刻度粗细,刻度粗细大于进度条宽度时,为系统默认粗细。 | 57 58 59## 示例 60 61```ts 62// xxx.ets 63@Entry 64@Component 65struct ProgressExample { 66 build() { 67 Column({ space: 15 }) { 68 Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') 69 Progress({ value: 10, type: ProgressType.Linear }).width(200) 70 Progress({ value: 20, total: 150, type: ProgressType.Linear }).color(Color.Grey).value(50).width(200) 71 72 73 Text('Eclipse Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') 74 Row({ space: 40 }) { 75 Progress({ value: 10, type: ProgressType.Eclipse }).width(100) 76 Progress({ value: 20, total: 150, type: ProgressType.Eclipse }).color(Color.Grey).value(50).width(100) 77 } 78 79 Text('ScaleRing Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') 80 Row({ space: 40 }) { 81 Progress({ value: 10, type: ProgressType.ScaleRing }).width(100) 82 Progress({ value: 20, total: 150, type: ProgressType.ScaleRing }) 83 .color(Color.Grey).value(50).width(100) 84 .style({ strokeWidth: 15, scaleCount: 15, scaleWidth: 5 }) 85 } 86 87 // scaleCount和scaleWidth效果对比 88 Row({ space: 40 }) { 89 Progress({ value: 20, total: 150, type: ProgressType.ScaleRing }) 90 .color(Color.Grey).value(50).width(100) 91 .style({ strokeWidth: 20, scaleCount: 20, scaleWidth: 5 }) 92 Progress({ value: 20, total: 150, type: ProgressType.ScaleRing }) 93 .color(Color.Grey).value(50).width(100) 94 .style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 3 }) 95 } 96 97 Text('Ring Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') 98 Row({ space: 40 }) { 99 Progress({ value: 10, type: ProgressType.Ring }).width(100) 100 Progress({ value: 20, total: 150, type: ProgressType.Ring }) 101 .color(Color.Grey).value(50).width(100) 102 .style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 20 }) 103 } 104 105 Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') 106 Row({ space: 40 }) { 107 Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50) 108 Progress({ value: 20, total: 150, type: ProgressType.Capsule }) 109 .color(Color.Grey) 110 .value(50) 111 .width(100) 112 .height(50) 113 } 114 }.width('100%').margin({ top: 30 }) 115 } 116} 117``` 118 119 120