欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 自定義Toast實(shí)例代碼

 更新時(shí)間:2017年06月12日 11:13:38   作者:UFO00001  
這篇文章主要介紹了微信小程序 自定義Toast實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下

微信小程序 自定義Toast實(shí)例代碼

Toast樣式可以根據(jù)需求自定義,本例中是圓形

<!--按鈕-->  
<view class="btn" bindtap="btn_toast">自定義Toast</view>  
<!--以下為toast顯示的內(nèi)容 opacity為透明度-->  
<view class="toast_box" style="opacity:{{0.9}}" wx:if="{{isShowToast}}">   
  {{toastText}}   
</view>  
<view class="toast_box" style="opacity:{{0.9}}" wx:if="{{isShowToast}}">   
  {{toastText1}}   
</view>  
Page {  
 background: #f9f9f9;  
}  
/*按鈕*/  
.btn {  
 width: 20%;   
 margin-left: 38%; 
 margin-top: 100rpx; 
 text-align: center;  
 border-radius: 10rpx;  
 border: 10px solid #f00;  
 background: #f00; 
 color: #fff;  
 font-size: 22rpx; 
}  
/*toast*/  
.toast_box {  
 width: 30%;  
 height: 221rpx; 
 margin-top: 60rpx;  
 margin-left: 35%; 
 text-align: center;  
 border-radius: 166rpx;  
 background: #f00; 
 color: #fff;  
 font-size: 32rpx; 
 line-height: 220rpx;  
}  
Page({ 
 
 /** 
  * 頁面的初始數(shù)據(jù) 
  */ 
 data: { 
  //toast默認(rèn)不顯示  
  isShowToast: false   
 }, 
 showToast: function () { 
  var _this = this; 
  // toast時(shí)間  
  _this.data.count = parseInt(_this.data.count) ? parseInt(_this.data.count) : 1000; 
  // 顯示toast  
  _this.setData({ 
   isShowToast: true, 
  }); 
  // 定時(shí)器關(guān)閉  
  setTimeout(function () { 
   _this.setData({ 
    isShowToast: false 
   }); 
  }, _this.data.count); 
 }, 
 /* 點(diǎn)擊按鈕 */ 
 btn_toast: function () { 
  console.log("點(diǎn)擊了按鈕") 
  //設(shè)置toast時(shí)間,toast內(nèi)容  
  this.setData({ 
   count: 1500, 
   toastText: '自定義', 
   toastText1: 'Toast' 
  }); 
  this.showToast(); 
 },  
 /** 
  * 生命周期函數(shù)--監(jiān)聽頁面加載 
  */ 
 onLoad: function (options) { 
  
 },}) 

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論