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

微信小程序?qū)崿F(xiàn)時間進度條功能

 更新時間:2020年11月17日 11:35:44   作者:£AP︶ㄣOL◢◤LO  
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)時間進度條功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

關(guān)于答題類,或者一些游戲環(huán)節(jié)的小程序需要用到時間進度條,該功能怎么實現(xiàn)?看下面源碼

<view class='out' style='margin-top:10px'>
 <view class='in' style='width:{{progressWidth}}%'></view>
</view>
<view class='caozuo'>
 <text>{{progressTime}}秒</text>
 <text bindtap='playbtn' data-change='1'>{{playPausetips}}</text>
</view>

CSS:

.out {margin-left:auto;margin-right:auto;width:250px;height:20px;border:1px solid red;border-radius:20px;overflow:hidden;}
.in {height:100%;background-color:red;}
.caozuo{font-size:14px;color:#333;margin-left:auto;margin-right:auto;width:250px;margin-top:10px;display: flex;justify-content:space-between}

JS:

Page({
 data: {
 progressWidth:0,
 progressTime:60,
 mark:true,
 playPausetips:"開始"
 },
 playbtn() {
 let that = this;
 let mark = that.data.mark;
 if (mark){
  that.timer = setInterval(that.run, 1000); //that.timer關(guān)鍵點
  wx.showToast({
  title: '開始',
  })
  that.setData({
  mark:false,
  playPausetips:"暫停"
  })
 }else{
  clearInterval(that.timer);
  wx.showToast({
  title: '暫停',
  })
  that.setData({
  mark: true,
  playPausetips: "開始"
  })
 }
 },
 run(){
 let that = this;
 let totalProgressTime = 60 //秒
 let progressWidth = that.data.progressWidth; //顯示進度
 let progressTime = that.data.progressTime; //時間
 
 if (progressWidth === 100) {
  wx.showToast({
  title: '結(jié)束回調(diào)處理',
  })
  clearInterval(that.timer);
  that.setData({
  progressTime: totalProgressTime, //進度條需要總時間s
  progressWidth: 100, //進度100%
  progressTime: 60
  })
  return;
 }
 progressTime--;
 progressWidth = (totalProgressTime - progressTime) * (100 / 60)
 that.setData({
  progressWidth: progressWidth,
  progressTime: progressTime
 })
 }
 
})

為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

广水市| 垫江县| 康平县| 公安县| 古浪县| 安顺市| 永川市| 正阳县| 松阳县| 赣榆县| 康平县| 广元市| 利川市| 刚察县| 富阳市| 苗栗县| 安丘市| 仁布县| 文成县| 江口县| 慈溪市| 连云港市| 安多县| 阿拉善左旗| 冀州市| 曲阜市| 安泽县| 长岛县| 鄂托克旗| 德兴市| 齐河县| 郯城县| 周至县| 广州市| 札达县| 当雄县| 四川省| 太仓市| 焉耆| 拜城县| 八宿县|