1e41f4b71Sopenharmony_ci# refresh 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci> **NOTE** 4e41f4b71Sopenharmony_ci> 5e41f4b71Sopenharmony_ci> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciThe **<refresh\>** component is used to refresh a page through a pull-down gesture. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Required Permissions 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciNone 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## Child Components 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciSupported 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## Attributes 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci| Name| Type| Default Value| Mandatory| Description| 24e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 25e41f4b71Sopenharmony_ci| offset | <length> | - | No| Distance to the top of the parent component from the **<refresh\>** component that comes to rest after a successful pull-down gesture.| 26e41f4b71Sopenharmony_ci| refreshing | boolean | false | No| Whether the **\<refresh>** component is being used for refreshing.| 27e41f4b71Sopenharmony_ci| type | string | auto | No| Dynamic effect when the component is refreshed. Two options are available and cannot be modified dynamically.<br>- **auto**: default effect. When the list is pulled to the top, the list does not move. When the list is pulled to the bottom, a circle is displayed.<br>- **pulldown**: When the list is pulled to the top, users can continue to pull down to trigger a refresh. The rebound effect will appear after the refresh. If the child component contains a list, set **scrolleffect** of the list to **no** to prevent drop-down effect conflicts.| 28e41f4b71Sopenharmony_ci| lasttime | boolean | false | No| Whether to display the last update time. The character string format is **last update time: XXXX**, where **XXXX** is displayed based on the certain time and date formats and cannot be dynamically modified. (It is recommended that this attribute be used when **type** is set to **pulldown**. The fixed distance is at the bottom of the content drop-down area. Pay attention to the **offset** attribute setting to prevent overlapping.)| 29e41f4b71Sopenharmony_ci| timeoffset<sup>6+</sup> | <length> | - | No| Distance between the update time and the top of the parent component.| 30e41f4b71Sopenharmony_ci| friction | number | 42 | No| Pull-down friction coefficient. The value ranges from 0 to 100. A larger value indicates a more responsive component. For example, if a user pulls the component down 100 px, it will actually move 100 * **friction**% px.| 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci## Styles 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-components-common-styles.md), the following styles are supported. 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| Name| Type| Default Value| Mandatory| Description| 38e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 39e41f4b71Sopenharmony_ci| background-color | <color> | white<br>| No| Background color of the **\<refresh>** component.| 40e41f4b71Sopenharmony_ci| progress-color | <color> | black<br>| No| Color of the loading icon of the **\<refresh>** component.| 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci## Events 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ciThe following events are supported. 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci| Name| Parameter| Description| 48e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 49e41f4b71Sopenharmony_ci| refresh | { refreshing: refreshingValue } | Triggered when the **\<refresh>** component is pulled down and the refresh status changes. Available values are as follows:<br>- **false**: The **\<refresh>** component is being pulled down.<br>- **true**: The **\<refresh>** component is not being pulled down.| 50e41f4b71Sopenharmony_ci| pulldown | { state: string } | Triggered when a user starts or stops pulling down the **\<refresh>** component. Available values are as follows:<br>- **start**: The pull-down starts.<br>- **end**: The pull-down ends.| 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci## Methods 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ciThe [universal methods](js-components-common-methods.md) are not supported. 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci## Example 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci```html 61e41f4b71Sopenharmony_ci<!-- xxx.hml --> 62e41f4b71Sopenharmony_ci<div class="container"> 63e41f4b71Sopenharmony_ci <refresh refreshing="{{fresh}}" onrefresh="refresh"> 64e41f4b71Sopenharmony_ci <list class="list" scrolleffect="no"> 65e41f4b71Sopenharmony_ci <list-item class="listitem" for="list"> 66e41f4b71Sopenharmony_ci <div class="content"> 67e41f4b71Sopenharmony_ci <text class="text">{{$item}}</text> 68e41f4b71Sopenharmony_ci </div> 69e41f4b71Sopenharmony_ci </list-item> 70e41f4b71Sopenharmony_ci </list> 71e41f4b71Sopenharmony_ci </refresh> 72e41f4b71Sopenharmony_ci</div> 73e41f4b71Sopenharmony_ci``` 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci```css 76e41f4b71Sopenharmony_ci/* xxx.css */ 77e41f4b71Sopenharmony_ci.container { 78e41f4b71Sopenharmony_ci flex-direction: column; 79e41f4b71Sopenharmony_ci align-items: center; 80e41f4b71Sopenharmony_ci width: 100%; 81e41f4b71Sopenharmony_ci height: 100%; 82e41f4b71Sopenharmony_ci} 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci.list { 85e41f4b71Sopenharmony_ci width: 100%; 86e41f4b71Sopenharmony_ci height: 100%; 87e41f4b71Sopenharmony_ci} 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci.listitem { 90e41f4b71Sopenharmony_ci width: 100%; 91e41f4b71Sopenharmony_ci height: 150px; 92e41f4b71Sopenharmony_ci} 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci.content { 95e41f4b71Sopenharmony_ci width: 100%; 96e41f4b71Sopenharmony_ci height: 100%; 97e41f4b71Sopenharmony_ci flex-direction: column; 98e41f4b71Sopenharmony_ci align-items: center; 99e41f4b71Sopenharmony_ci justify-content: center; 100e41f4b71Sopenharmony_ci} 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci.text { 103e41f4b71Sopenharmony_ci font-size: 35px; 104e41f4b71Sopenharmony_ci font-weight: bold; 105e41f4b71Sopenharmony_ci} 106e41f4b71Sopenharmony_ci``` 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci```js 109e41f4b71Sopenharmony_ci// xxx.js 110e41f4b71Sopenharmony_ciimport promptAction from '@ohos.promptAction'; 111e41f4b71Sopenharmony_ciexport default { 112e41f4b71Sopenharmony_ci data: { 113e41f4b71Sopenharmony_ci list:[], 114e41f4b71Sopenharmony_ci fresh:false 115e41f4b71Sopenharmony_ci }, 116e41f4b71Sopenharmony_ci onInit() { 117e41f4b71Sopenharmony_ci this.list = []; 118e41f4b71Sopenharmony_ci for (var i = 0; i <= 3; i++) { 119e41f4b71Sopenharmony_ci var item ='List element' + i; 120e41f4b71Sopenharmony_ci this.list.push(item); 121e41f4b71Sopenharmony_ci } 122e41f4b71Sopenharmony_ci }, 123e41f4b71Sopenharmony_ci refresh: function (e) { 124e41f4b71Sopenharmony_ci promptAction.showToast({ 125e41f4b71Sopenharmony_ci message: 'Refreshing...' 126e41f4b71Sopenharmony_ci }) 127e41f4b71Sopenharmony_ci var that = this; 128e41f4b71Sopenharmony_ci that.fresh = e.refreshing; 129e41f4b71Sopenharmony_ci setTimeout(function () { 130e41f4b71Sopenharmony_ci that.fresh = false; 131e41f4b71Sopenharmony_ci var addItem ='Refresh element'; 132e41f4b71Sopenharmony_ci that.list.unshift(addItem); 133e41f4b71Sopenharmony_ci promptAction.showToast({ 134e41f4b71Sopenharmony_ci message: 'Refreshed.' 135e41f4b71Sopenharmony_ci }) 136e41f4b71Sopenharmony_ci }, 2000) 137e41f4b71Sopenharmony_ci } 138e41f4b71Sopenharmony_ci} 139e41f4b71Sopenharmony_ci``` 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci 142