百度智能小程序 停止下拉刷新

2020-09-05 14:11 更新

swan.stopPullDownRefresh

解释: 停止当前页面下拉刷新。

方法参数

示例 

在开发者工具中打开



图片示例



代码示例

<view class="wrap">
    <view class="card-area">
        <view class="page-info">下拉页面/点击按钮即可刷新</view>
        <button bind:tap="startPullDownRefresh" disabled="{{disabled}}" hover-stop-propagation="true" type="primary">开始刷新</button>
        <button bind:tap="stopPullDownRefresh" hover-stop-propagation="true" type="primary">停止刷新</button>
        <button data-set="{{textStyle}}" bind:tap="setBackgroundTextStyle" hover-stop-propagation="true" type="primary">点击切换loading样式为:{{textStyle}}</button>
    </view>
</view>
Page({
    data: {
        textStyle: 'dark',
        disabled: false
    },

    startPullDownRefresh() {
        // 若要触发用户手动下拉刷新,在json文件中设置 "enablePullDownRefresh": true
        swan.startPullDownRefresh({
            success: res => {
                this.setData('disabled', true);
                console.log('startPullDownRefresh success', res);
            },
            fail: err => {
                console.log('startPullDownRefresh fail', err);
            }
        });
    },

    stopPullDownRefresh() {
        swan.stopPullDownRefresh();
        this.setData('disabled', false);
    },

    setBackgroundTextStyle(e) {
        let textStyle = e.target.dataset.set;
        swan.setBackgroundTextStyle({
            textStyle: textStyle,
            success: () => {
                console.log('setBackgroundTextStyle success');
                if (textStyle === 'dark') {
                    this.setData('textStyle', 'light');
                }
                else {
                    this.setData('textStyle', 'dark');
                }
            },
            fail: err => {
                console.log('setBackgroundTextStyle fail', err);
            }
        });

    }
});

错误码

Android

错误码说明

1001

执行失败

iOS

错误码说明

201

解析失败,请检查调起协议是否合法。


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号