1. 程式人生 > >微信小程序 toast

微信小程序 toast

nta dde spa {} data 默認 ber CI HR

消息提示框

屬性名類型默認值說明
duration Float 1500 hidden設置false後,觸發bindchange的延時,單位毫秒
hidden Boolean false 是否隱藏
bindchange EventHandle duration延時後觸發

示例代碼:

1 2 3 4 5 6 7 8 9 10 11 12 <view class="body-view"> <toast hidden="{{toast1Hidden}}" bindchange="toast1Change"> 默認 </toast>
<button type="default" bindtap="toast1Tap">點擊彈出默認toast</button> </view> <view class="body-view"> <toast hidden="{{toast2Hidden}}" duration="3000" bindchange="toast2Change"> 設置duration </toast> <button type="default" bindtap="toast2Tap">點擊彈出設置duration的toast</button>
</view>
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 var toastNum = 2 var pageData = {} pageData.data = {} for (var i = 0; i <= toastNum; ++i) { pageData.data[‘toast‘+i+‘Hidden‘] = true; (function (index) { pageData[‘toast‘+index+‘Change‘] = function(e) { var obj = {}
obj[‘toast‘+index+‘Hidden‘] = true; this.setData(obj) } pageData[‘toast‘+index+‘Tap‘] = function(e) { var obj = {} obj[‘toast‘+index+‘Hidden‘] = false this.setData(obj) } })(i) } Page(pageData)

技術分享圖片

微信小程序 toast