Item | Description |
|---|---|
Applicable devices | Mobile phones, tablets, and telematics devices |
Applicable regions | Global |
In addition to general attributes, the attributes listed in the following table are supported.
Attribute | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
offset | length | 132px | No | Distance from a refresh element to the top of this view when the element is not moved. |
refreshing | boolean | false | No | Indicates whether the page is being refreshed by this element. |
type (1020+) | string | material | No | As an exclusive extension for quick apps to be used on Huawei phones, the following two values are available (invalid for apps of other vendors) and the value cannot be dynamically modified.
In quick app specifications by the smartphone vendor alliance, the following two values are available and the value cannot be dynamically modified (in 1035+ versions).
NOTE: Scrolling down at the top of the page will refresh the page but will not trigger the callback of onReachTop. |
enable-refresh (1080+) | boolean | true | No | Indicates whether to enable the refresh element. |
In addition to common styles, the styles listed in the following table are supported.
Style | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
background-color | color | white | No | Background color of a refresh element. |
progress-color | color | black | No | Loading color of a refresh element. |
Versions earlier than 1040 do not support the click, touch, or longpress events. In addition to common events, the event listed in the following table is supported.
Event | Parameter | Triggering Condition |
|---|---|---|
refresh | {refreshing: refreshingValue} | A user pulls down a refresh element. |
A page stops moving when the scroll boundary is reached.
<template>
<div class="container">
<!-- The refreshing attribute is used to identify the loading status of a refresh element.-->
<refresh class="refresh" onrefresh="refresh" refreshing="{{isRefreshing}}" offset=800px type="pulldown" enable-refresh="{{enableRefresh}}">
<div class="page-title-wrap">
<text class="page-title ">{{componentName}}</text>
</div>
<div class="item-container">
<input class="btn" type="button" value="{{$t('message.component.refresh.stopRefresh')}}" onclick="stopRefresh" />
</div>
<div class="item-container">
<input class="btn" type="button" value="enable refresh" onclick="isEnableRefresh"/>
</div>
</refresh>
</div>
</template>
<style>
@import '../Common/css/common.css';
.refresh {
background-color: #FFFFFF;
progress-color: #0faeff;
flex-direction: column;
flex: 1;
}
.item-container {
margin-bottom: 50px;
margin-right: 60px;
margin-left: 60px;
flex-direction: column;
}
</style>
<script>
import prompt from '@system.prompt'
export default {
data: {
componentName: 'refresh',
isRefreshing: false,
enableRefresh :true
},
onInit() {
this.$page.setTitleBar({ text: 'refresh' })
},
refresh: function (e) {
prompt.showToast({
message:this.$t('message.component.refresh.refreshing')
})
var that = this;
// Update the refresh status. (If the value of refreshing is changed from false to true or from true to false, the refresh element status is updated.
that.isRefreshing = e.refreshing;
setTimeout(function () {
// Disable the refresh function.
that.isRefreshing = false;
prompt.showToast({
message:that.$t('message.component.refresh.refreshComplete')
})
}, 3000)
},
isEnableRefresh :function() {
this.enableRefresh = !this.enableRefresh
prompt.showToast({
message:this.enableRefresh
})
},
stopRefresh: function () {
this.isRefreshing = false;
}
}
</script> The following figure shows the final effect.

A page moves a little further when the scroll boundary is reached.
<template>
<div>
<!-- The refreshing attribute is used to identify the loading status of a refresh element.-->
<refresh onrefresh="refresh" refreshing="{{isRefreshing}}" offset=800px type = "overscroll">
<div>
<text class="page-title ">{{componentName}}</text>
</div>
<div>
<input type="button" value="Stop refreshing" onclick="stopRefresh" />
</div>
</refresh>
</div>
</template>
<style>
@import '../Common/css/common.css';
.refresh {
background-color: #FFFFFF;
progress-color: #0faeff;
flex-direction: column;
flex: 1;
}
.item-container {
margin-bottom: 50px;
margin-right: 60px;
margin-left: 60px;
flex-direction: column;
}
</style>
<script>
import prompt from '@system.prompt'
export default {
data: {
componentName: 'refresh',
isRefreshing: false,
},
onInit() {
this.$page.setTitleBar({ text: 'refresh' })
},
refresh: function (e) {
prompt.showToast({
message: 'Refreshing...'
})
var that = this;
// Update the refresh status. (If the value of refreshing is changed from false to true or from true to false, the refresh element status is updated.
that.isRefreshing = e.refreshing;
setTimeout(function () {
// Disable the refresh function.
that.isRefreshing = false;
prompt.showToast({
message: 'Refreshed'
})
}, 3000)
},
stopRefresh: function () {
this.isRefreshing = false;
},
}
</script> The following figure shows the final effect.

A page (with the list displayed) stops moving when the scroll boundary is reached.
<template>
<div>
<!-- The refreshing attribute is used to identify the loading status of a refresh element.-->
<refresh onrefresh="refresh" refreshing="{{isRefreshing}}" offset=800px type="material">
<div>
<text class="page-title ">{{componentName}}</text>
</div>
<div>
<input type="button" value="Stop refreshing" onclick="stopRefresh" />
</div>
<!-- List -->
<list onscrollbottom="scrollbottom" onscrolltop="scrolltop" onscroll="scroll" id="list" scrollpage="{{scrollPage}}">
<!--Set the list items. If they have the same value of their type attribute, it is necessary to ensure that they have completely identical rendered layout. In this case, use show instead of if to ensure that the layout does not change.-->
<list-item type="listItem" class="item item-color" for="{{listData}}">
<text>{{$item}}--{{$idx}}</text>
</list-item>
<!--Load more.-->
<list-item type="loadMore" if="{{loadMore}}">
<progress type="circular"></progress>
<text>Load more.</text>
</list-item>
</list>
</refresh>
</div>
</template>
<style>
@import '../Common/css/common.css';
.refresh {
background-color: #FFFFFF;
progress-color: #0faeff;
flex-direction: column;
flex: 1;
}
.item-container {
margin-bottom: 50px;
margin-right: 60px;
margin-left: 60px;
flex-direction: column;
}
.list {
flex-direction: column;
flex: 1;
padding-left: 60px;
padding-right: 60px;
columns: 4;
border-color: #FF0000;
border-width: 5px;
}
.item {
height: 150px;
align-items: flex-start;
margin-bottom: 15px;
border-color: #9400D3;
border-width: 5px;
margin-right: 20px;
}
.load-more {
justify-content: center;
align-items: center;
height: 100px;
border-color: #bbbbbb;
border-bottom-width: 1px;
}
.item-color {
background-color: #f76160;
}
</style>
<script>
import prompt from '@system.prompt'
export default {
data: {
componentName: 'refresh',
isRefreshing: false,
loadMore: true,
listAdd: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
listData: [],
scrollPage: false,
showListBtn: true,
listClass: 'selected',
arrayClass: '',
},
onInit() {
this.$page.setTitleBar({ text: 'refresh' })
// Initialize list data.
this.listData = [].concat(this.listAdd);
},
refresh: function (e) {
prompt.showToast({
message: 'Refreshing...'
})
var that = this;
// Update the refresh status. (If the value of refreshing is changed from false to true or from true to false, the refresh element status is updated.
that.isRefreshing = e.refreshing;
setTimeout(function () {
// Disable the refresh function.
that.isRefreshing = false;
prompt.showToast({
message: 'Refreshed'
})
}, 3000)
},
stopRefresh: function () {
this.isRefreshing = false;
},
scrollbottom: function () {
prompt.showToast({
message:'Bottom reached.'
})
// Load the next page.
var that = this;
var renderData = [].concat(that.listData, that.listAdd);
setTimeout(function () {
that.listData = renderData;
}, 1000)
},
scrolltop: function () {
prompt.showToast({
message: 'Top reached.'
})
},
// Set a scrolling listener.
scroll: function (e) {
let msg = "Scrolling.scrollX:" + e.scrollX
+ " .scrollY:" + e.scrollY
+ " .scrollState:" + e.scrollState;
console.info(msg);
}
}
</script> The following figure shows the final effect.

A page (with the list displayed) moves a little further when the scroll boundary is reached.
<template>
<div>
<!-- The refreshing attribute is used to identify the loading status of a refresh element.-->
<refresh onrefresh="refresh" refreshing="{{isRefreshing}}" offset=800px type="overscroll">
<div>
<text class="page-title ">{{componentName}}</text>
</div>
<div>
<input type="button" value="Stop refreshing" onclick="stopRefresh" />
</div>
<!-- List -->
<list onscrollbottom="scrollbottom" onscrolltop="scrolltop" onscroll="scroll" id="list" scrollpage="{{scrollPage}}">
<!--Set the list items. If they have the same value of their type attribute, it is necessary to ensure that they have completely identical rendered layout. In this case, use show instead of if to ensure that the layout does not change.-->
<list-item type="listItem" class="item item-color" for="{{listData}}">
<text>{{$item}}--{{$idx}}</text>
</list-item>
<!--Load more.-->
<list-item type="loadMore" if="{{loadMore}}">
<progress type="circular"></progress>
<text>Load more.</text>
</list-item>
</list>
</refresh>
</div>
</template>
<style>
@import '../Common/css/common.css';
.refresh {
background-color: #FFFFFF;
progress-color: #0faeff;
flex-direction: column;
flex: 1;
}
.item-container {
margin-bottom: 50px;
margin-right: 60px;
margin-left: 60px;
flex-direction: column;
}
.list {
flex-direction: column;
flex: 1;
padding-left: 60px;
padding-right: 60px;
columns: 4;
border-color: #FF0000;
border-width: 5px;
}
.item {
height: 150px;
align-items: flex-start;
margin-bottom: 15px;
border-color: #9400D3;
border-width: 5px;
margin-right: 20px;
}
.load-more {
justify-content: center;
align-items: center;
height: 100px;
border-color: #bbbbbb;
border-bottom-width: 1px;
}
.item-color {
background-color: #f76160;
}
</style>
<script>
import prompt from '@system.prompt'
export default {
data: {
componentName: 'refresh',
isRefreshing: false,
loadMore: true,
listAdd: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
listData: [],
scrollPage: false,
showListBtn: true,
listClass: 'selected',
arrayClass: '',
},
onInit() {
this.$page.setTitleBar({ text: 'refresh' })
// Initialize list data.
this.listData = [].concat(this.listAdd);
},
refresh: function (e) {
prompt.showToast({
message: 'Refreshing...'
})
var that = this;
// Update the refresh status. (If the value of refreshing is changed from false to true or from true to false, the refresh element status is updated.
that.isRefreshing = e.refreshing;
setTimeout(function () {
// Disable the refresh function.
that.isRefreshing = false;
prompt.showToast({
message: 'Refreshed'
})
}, 3000)
},
stopRefresh: function () {
this.isRefreshing = false;
},
scrollbottom: function () {
prompt.showToast({
message:'Bottom reached.'
})
// Load the next page.
var that = this;
var renderData = [].concat(that.listData, that.listAdd);
setTimeout(function () {
that.listData = renderData;
}, 1000)
},
scrolltop: function () {
prompt.showToast({
message: 'Top reached.'
})
},
// Set a scrolling listener.
scroll: function (e) {
let msg = "Scrolling.scrollX:" + e.scrollX
+ " .scrollY:" + e.scrollY
+ " .scrollState:" + e.scrollState;
console.info(msg);
}
}
</script> The following figure shows the final effect.

Version | Date | Description |
|---|---|---|
1080 | 2021-12-28 | Added the enable-refresh attribute. The default value is true. If the parameter value is not set, the default value will be used. |
1020 | 2018-06-20 | Added the type attribute. The default value is material. If the attribute is not set, the default value will be used. |