1e41f4b71Sopenharmony_ci# progress 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci进度条,用于显示内容加载或操作处理进度。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 该组件从从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## 子组件 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci不支持。 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## 属性 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci| 名称 | 类型 | 默认值 | 必填 | 描述 | 18e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 19e41f4b71Sopenharmony_ci| type | string | horizontal | 否 | 设置进度条的类型,该属性不支持动态修改,可选值为:<br/>- horizontal:线性进度条;<br/>- arc:弧形进度条。 | 20e41f4b71Sopenharmony_ci| id | string | - | 否 | 组件的唯一标识。 | 21e41f4b71Sopenharmony_ci| style | string | - | 否 | 组件的样式声明。 | 22e41f4b71Sopenharmony_ci| class | string | - | 否 | 组件的样式类,用于引用样式表。 | 23e41f4b71Sopenharmony_ci| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci不同类型的进度条还支持不同的属性: 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci- 类型为horizontal时,支持如下属性: 28e41f4b71Sopenharmony_ci | 名称 | 类型 | 默认值 | 必填 | 描述 | 29e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | -------- | 30e41f4b71Sopenharmony_ci | percent | number | 0 | 否 | 当前进度。取值范围为0-100。 | 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci- 类型为arc时,支持如下属性: 33e41f4b71Sopenharmony_ci | 名称 | 类型 | 默认值 | 必填 | 描述 | 34e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | -------- | 35e41f4b71Sopenharmony_ci | percent | number | 0 | 否 | 当前进度。取值范围为0-100。 | 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci## 事件 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci| 名称 | 参数 | 描述 | 41e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 42e41f4b71Sopenharmony_ci| click | - | 点击动作触发该事件。 | 43e41f4b71Sopenharmony_ci| longpress | - | 长按动作触发该事件。 | 44e41f4b71Sopenharmony_ci| swipe<sup>5+</sup> | [SwipeEvent](js-lite-common-events.md) | 组件上快速滑动后触发。 | 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci## 样式 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci- type为horizontal,支持如下样式: 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci | 名称 | 类型 | 默认值 | 必填 | 描述 | 52e41f4b71Sopenharmony_ci | ------------ | -------------- | ---------------------------------------------- | ---- | ------------------ | 53e41f4b71Sopenharmony_ci | color | <color> | \#6b9ac7 | 否 | 设置进度条的颜色。 | 54e41f4b71Sopenharmony_ci | stroke-width | <length> | 32<sup>1-4 </sup>\| 4<sup>5+</sup>px | 否 | 设置进度条的宽度。 | 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci- type为arc,支持如下样式: 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci | 名称 | 类型 | 默认值 | 必填 | 描述 | 59e41f4b71Sopenharmony_ci | ---------------- | -------------- | ------ | ---- | ------------------------------------------------------------ | 60e41f4b71Sopenharmony_ci | color | <color> | - | 否 | 弧形进度条的颜色。 | 61e41f4b71Sopenharmony_ci | background-color | <color> | - | 否 | 弧形进度条的背景色。 | 62e41f4b71Sopenharmony_ci | stroke-width | <length> | - | 否 | 弧形进度条的宽度。<br/>进度条宽度越大,进度条越靠近圆心。即进度条始终在半径区域内。 | 63e41f4b71Sopenharmony_ci | start-angle | <deg> | 240 | 否 | 弧形进度条起始角度,以时钟0点为基线。范围为0到360(顺时针)。 | 64e41f4b71Sopenharmony_ci | total-angle | <deg> | 240 | 否 | 弧形进度条总长度,范围为-360到360,负数标识起点到终点为逆时针。 | 65e41f4b71Sopenharmony_ci | center-x | <length> | - | 否 | 弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-y和radius一起。 | 66e41f4b71Sopenharmony_ci | center-y | <length> | - | 否 | 弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-x和radius一起。 | 67e41f4b71Sopenharmony_ci | radius | <length> | - | 否 | 弧形进度条半径,该样式需要和center-x和center-y一起。 | 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci除上述样式之外,还支持如下样式: 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci| 名称 | 类型 | 默认值 | 必填 | 描述 | 72e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 73e41f4b71Sopenharmony_ci| width | <length> \| <percentage><sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/>未设置时组件宽度默认为0。 | 74e41f4b71Sopenharmony_ci| height | <length> \| <percentage><sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/>未设置时组件高度默认为0。 | 75e41f4b71Sopenharmony_ci| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/> 该属性可以有1到4个值:<br/>- 指定一个值时,该值指定四个边的内边距。<br/>- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | 76e41f4b71Sopenharmony_ci| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | 77e41f4b71Sopenharmony_ci| margin | <length> \| <percentage><sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br>- 只有一个值时,这个值会被指定给全部的四个边。<br/>- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。<br/>- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | 78e41f4b71Sopenharmony_ci| margin-[left\|top\|right\|bottom] | <length> \| <percentage><sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 | 79e41f4b71Sopenharmony_ci| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | 80e41f4b71Sopenharmony_ci| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | 81e41f4b71Sopenharmony_ci| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | 82e41f4b71Sopenharmony_ci| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>- flex:弹性布局。<br/>- none:不渲染此元素。 | 83e41f4b71Sopenharmony_ci| [left\|top] | <length> \| <percentage><sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci## 示例 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci```html 88e41f4b71Sopenharmony_ci<!-- xxx.hml --> 89e41f4b71Sopenharmony_ci<div class="container"> 90e41f4b71Sopenharmony_ci <progress type="horizontal" percent="{{horizontalVal}}" style="height: 10%;width: 40%;" onclick = "changeHorizontal"></progress> 91e41f4b71Sopenharmony_ci <progress type="arc" class="min-progress" percent="{{arcVal}}" on:click="changeArc"></progress> 92e41f4b71Sopenharmony_ci</div> 93e41f4b71Sopenharmony_ci``` 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci```css 96e41f4b71Sopenharmony_ci/* xxx.css */ 97e41f4b71Sopenharmony_ci.container { 98e41f4b71Sopenharmony_ci flex-direction: column; 99e41f4b71Sopenharmony_ci height: 100%; 100e41f4b71Sopenharmony_ci width: 100%; 101e41f4b71Sopenharmony_ci align-items: center; 102e41f4b71Sopenharmony_ci} 103e41f4b71Sopenharmony_ci.min-progress { 104e41f4b71Sopenharmony_ci width: 300px; 105e41f4b71Sopenharmony_ci height: 300px; 106e41f4b71Sopenharmony_ci} 107e41f4b71Sopenharmony_ci``` 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci```javascript 110e41f4b71Sopenharmony_ci// xxx.js 111e41f4b71Sopenharmony_ciexport default { 112e41f4b71Sopenharmony_ci data: { 113e41f4b71Sopenharmony_ci arcVal: 0, 114e41f4b71Sopenharmony_ci horizontalVal: 0 115e41f4b71Sopenharmony_ci }, 116e41f4b71Sopenharmony_ci changeArc() { 117e41f4b71Sopenharmony_ci this.arcVal+= 10; 118e41f4b71Sopenharmony_ci }, 119e41f4b71Sopenharmony_ci changeHorizontal() { 120e41f4b71Sopenharmony_ci this.horizontalVal+= 10; 121e41f4b71Sopenharmony_ci } 122e41f4b71Sopenharmony_ci} 123e41f4b71Sopenharmony_ci``` 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci