百度智能小程序 隱藏消息提示框

2020-09-05 14:09 更新

swan.hideToast

解釋: 隱藏消息提示框

方法參數(shù)

Object object

object參數(shù)說明

屬性名類型必填默認(rèn)值說明

success

function

接口調(diào)用成功的回調(diào)函數(shù)

fail

function

接口調(diào)用失敗的回調(diào)函數(shù)

complete

function

接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

示例 

在開發(fā)者工具中打開



圖片示例



代碼示例

<view class="wrap">
    <view class="card-area" s-if="{{!isWeb}}">
        <view class="top-description border-bottom">默認(rèn)樣式</view>
        <button bindtap="showToast" type="primary" hover-stop-propagation="true">默認(rèn)toast</button>   
    </view>
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>設(shè)置不顯示圖標(biāo)</view>
            <view>icon: 'none'</view>
        </view>
        <button bindtap="showToastIcon" type="primary" hover-stop-propagation="true">無圖標(biāo)toast</button>
    </view>
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>設(shè)置顯示loading圖標(biāo)</view>
            <view>icon: 'loading'</view>
        </view>
        <button bindtap="showToastLoading" type="primary" hover-stop-propagation="true">loading toast</button>
    </view>
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>設(shè)置延遲時間</view>
            <view>duration: 5000</view>
        </view>
        <button bindtap="showToastDuration" type="primary" hover-stop-propagation="true">延遲5000毫秒的toast</button>
    </view>

    <view class="card-area">
        <view class="top-description border-bottom">隱藏toast</view>
        <button bindtap="hideToast" type="primary" disabled="{{disabled}}" hover-stop-propagation="true">隱藏toast</button>
    </view>
</view>
Page({
    data: {
        disabled: true,
        isWeb: true
    },
    onShow() {
        swan.getSystemInfo({
            success: res => {
                this.setData('isWeb', res.platform === 'web');
            }
        });
    },

    showToast() {
        swan.showToast({
            title: '默認(rèn)toast',
            mask: false,
            success: res => {
                this.setData({'disabled': false});
            },
            fail: err => {
                console.log('showToast fail', err);
            }
        });
    },

    showToastIcon() {
        swan.showToast({
            title: '單行最多十四個文字單行最多十四個文字',
            icon: 'none',
            mask: false,
            success: res => {
                this.setData({'disabled': false});
            },
            fail: err => {
                console.log('showToast fail', err);
            }
        });
    },

    showToastLoading() {
        swan.showToast({
            title: '正在加載...',
            icon: 'loading',
            mask: true,
            success: res => {
                this.setData({'disabled': false});
            },
            fail: err => {
                console.log('showToast fail', err);
            }
        });
    },

    showToastDuration() {
        swan.showToast({
            duration: 5000,
            title: '5000毫秒后隱藏',
            icon: 'none',
            mask: false,
            success: res => {
                this.setData({'disabled': false});
            },
            fail: err => {
                console.log('showToast fail', err);
            }
        });
    },

    hideToast() {
        swan.hideToast();
        swan.hideLoading();
    }
});

錯誤碼

Android

錯誤碼說明

1001

執(zhí)行失敗


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號