最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序 Toast自定義實(shí)例詳解

 更新時(shí)間:2017年01月20日 17:04:57   投稿:lqh  
這篇文章主要介紹了微信小程序 Toast自定義實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下

微信小程序 Toast自定義實(shí)例詳解

實(shí)現(xiàn)類似于Android的Toast提示 

index.js:

var timer; 
var inputinfo = ""; 
var app = getApp() 
Page({ 
 data: { 
  animationData:"", 
  showModalStatus:false 
 }, 
  
 onLoad: function () { 
   
 }, 
 showModal: function () { 
  // 顯示遮罩層 
  var animation = wx.createAnimation({ 
   duration: 200, 
   timingFunction: "linear", 
   delay: 0 
  }) 
  this.animation = animation 
  animation.translateY(200).step() 
  this.setData({ 
   animationData: animation.export(), 
   showModalStatus: true 
  }) 
  setTimeout(function () { 
   animation.translateY(0).step() 
   this.setData({ 
    animationData: animation.export() 
   }) 
  }.bind(this), 200) 
  console.log("準(zhǔn)備執(zhí)行"); 
   timer = setTimeout(function () { 
    if(this.data.showModalStatus){ 
     this.hideModal(); 
     console.log("是否執(zhí)行"); 
   } 
  }.bind(this), 3000) 
 }, 
 clickbtn:function(){ 
  if(this.data.showModalStatus){ 
   this.hideModal(); 
  }else{ 
   this.showModal(); 
  } 
 }, 
 hideModal: function () { 
  if(timer != null){ 
   clearTimeout(timer); 
   timer = null; 
  } 
  // 隱藏遮罩層 
  var animation = wx.createAnimation({ 
   duration: 200, 
   timingFunction: "linear", 
   delay: 0 
  }) 
  this.animation = animation 
  animation.translateY(200).step() 
  this.setData({ 
   animationData: animation.export(), 
  }) 
  setTimeout(function () { 
   animation.translateY(0).step() 
   this.setData({ 
    animationData: animation.export(), 
    showModalStatus: false 
   }) 
  }.bind(this), 200) 
 }, 
}) 

index.wxml:

<button type="default" bindtap="clickbtn"> 
 點(diǎn)擊 
</button> 
<view class="commodity_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view> 
<view animation="{{animationData}}" class="commodity_attr_box" wx:if="{{showModalStatus}}"> 
<!--對(duì)話框標(biāo)題--> 
 <view class="title-view"> 
  <view class="toast-view"> 
   要顯示的內(nèi)容 
  </view> 
   
 </view> 
</view> 

效果圖:

源碼下載鏈接:http://xiazai.jb51.net/201701/yuanma/toastTestNew(jb51.net).rar

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

相關(guān)文章

最新評(píng)論

永寿县| 新泰市| 都江堰市| 金乡县| 通许县| 大冶市| 镇坪县| 苏尼特右旗| 仁寿县| 芜湖县| 即墨市| 武穴市| 江阴市| 龙口市| 水城县| 靖江市| 织金县| 平顶山市| 寻甸| 南陵县| 绥化市| 江口县| 洞头县| 都昌县| 宜城市| 扎兰屯市| 滦平县| 扶余县| 兰坪| 读书| 阿尔山市| 东明县| 新津县| 双城市| 德惠市| 临朐县| 郁南县| 冀州市| 玉龙| 灵寿县| 正镶白旗|