W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
解釋: 隱藏消息提示框
Object object
屬性名 | 類型 | 必填 | 默認(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í)行) |
<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();
}
});
錯誤碼 | 說明 |
---|---|
1001 | 執(zhí)行失敗 |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: