Use the pull-down refresh APIs to trigger, monitor, and stop pull-down refresh on mini program pages. Requires mPaaS 10.1.32 or later.
onPullDownRefresh
Supported in mPaaS 10.1.32 and later.
Define the onPullDownRefresh function on a Page to listen for pull-down refresh events.
-
Set
"pullRefresh":truein the page.jsonfile and"allowsBounceVertical":"YES"inwindowofapp.json. -
Calling my.startPullDownRefresh triggers the refresh animation and fires the
onPullDownRefreshcallback, the same as a manual pull-down. -
Call my.stopPullDownRefresh to stop the refresh animation after data loading completes.
Parameters
|
Attribute |
Type |
Required |
Description |
|
pullRefresh |
Boolean |
No |
Enables pull-down refresh. Default: true. Takes effect only when |
|
allowsBounceVertical |
String |
No |
Allows vertical over-scroll beyond page content. Default: YES. Valid values: YES, NO. |
Code sample
onPullDownRefresh example:
// API-DEMO page/API/pull-down-refresh/pull-down-refresh.json
{
"defaultTitle": "Pull-down refresh",
"pullRefresh": true
}<!-- API-DEMO page/API/pull-down-refresh/pull-down-refresh.axml-->
<view class="page">
<view class="page-section">
<view class="page-section-title">Pull down the page to refresh</view>
<view class="page-section-btns">
<view type="primary" onTap="stopPullDownRefresh">Stop refresh</view>
</view>
</view>
</view>// API-DEMO page/API/pull-down-refresh/pull-down-refresh.js
Page({
onPullDownRefresh() {
console.log('onPullDownRefresh', new Date());
},
stopPullDownRefresh() {
my.stopPullDownRefresh({
complete(res) {
console.log(res, new Date())
}
})
}
});
my.stopPullDownRefresh
Supported in mPaaS 10.1.32 and later.
Stops the pull-down refresh animation on the current page.
-
Calling my.startPullDownRefresh triggers the refresh animation and fires onPullDownRefresh, the same as a manual pull-down.
-
Call my.stopPullDownRefresh to stop the refresh animation after data loading completes.
Parameters
Object with the following attributes:
|
Attribute |
Type |
Required |
Description |
|
success |
Function |
No |
Called on success. |
|
fail |
Function |
No |
Called on failure. |
|
complete |
Function |
No |
Called when the call completes, regardless of success or failure. |
Code sample
my.stopPullDownRefresh example:
// API-DEMO page/API/pull-down-refresh/pull-down-refresh.json
{
"defaultTitle": "Pull-down refresh",
"pullRefresh": true
}<!-- API-DEMO page/API/pull-down-refresh/pull-down-refresh.axml-->
<view class="page">
<view class="page-section">
<view class="page-section-title">Pull down the page to refresh</view>
<view class="page-section-btns">
<view type="primary" onTap="stopPullDownRefresh">Stop refresh</view>
</view>
</view>
</view>// API-DEMO page/API/pull-down-refresh/pull-down-refresh.js
Page({
onPullDownRefresh() {
console.log('onPullDownRefresh', new Date());
},
stopPullDownRefresh() {
my.stopPullDownRefresh({
complete(res) {
console.log(res, new Date())
}
})
}
});
my.startPullDownRefresh
Supported in mPaaS 10.1.32 and later.
Starts the pull-down refresh animation on the current page.
-
Calling my.startPullDownRefresh triggers the refresh animation and fires onPullDownRefresh, the same as a manual pull-down.
-
Call my.stopPullDownRefresh to stop the refresh animation after data loading completes.
-
my.startPullDownRefreshis not affected byallowsBounceVerticalorpullRefresh.
Parameters
Object with the following attributes:
|
Attribute |
Type |
Required |
Description |
|
success |
Function |
No |
Called on success. |
|
fail |
Function |
No |
Called on failure. |
|
complete |
Function |
No |
Called when the call completes, regardless of success or failure. |
Code sample
my.startPullDownRefresh example:
my.startPullDownRefresh()