阅读(2235) (4)

百度智能小程序 设置窗口下拉背景loading样式

2020-08-13 15:46:14 更新

swan.setBackgroundTextStyle

基础库 3.10.4 版本开始支持。

解释:设置窗口下拉背景 loading 样式。

方法参数

Object object

object参数说明

属性名类型必填默认值说明

textStyle

String

loading 图样式,有效值 light 和 dark 。11.3
低版本请做兼容性处理

success

Function

接口调用成功的回调函数

fail

Function

接口调用失败的回调函数

complete

Function

接口调用结束的回调函数(调用成功、失败都会执行)

示例 

在开发者工具中打开



图片示例



代码示例

<view class="wrap">
    <button bind:tap="setBackgroundTextStyle" hover-stop-propagation="true" type="primary">点击切换loading样式为:{{textStyle}}</button>
</view>
Page({
    data: {
        textStyle: 'dark'
    },
    onShow() {
        this.setBackgroundTextStyle();
        swan.startPullDownRefresh();
    },
    setBackgroundTextStyle() {
        let textStyle = this.data.textStyle;
        swan.setBackgroundTextStyle({
            textStyle: textStyle,
            success: () => {
                console.log('setBackgroundTextStyle success');
                textStyle === 'dark' 
                ?this.setData('textStyle', 'light')
                :this.setData('textStyle', 'dark');
            },
            fail: err => {
                console.log('setBackgroundTextStyle fail', err);
            }
        });
    }
});
{
    "navigationBarTitleText": "setBackgroundTextStyle",
    "enablePullDownRefresh": true
}


错误码

Android

错误码说明

202

解析失败,请检查参数是否正确

1001

执行失败

iOS

错误码说明

202

解析失败,请检查参数是否正确