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

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

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

關(guān)于答題類(lèi),或者一些游戲環(huán)節(jié)的小程序需要用到時(shí)間進(jìn)度條,該功能怎么實(shí)現(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:"開(kāi)始"
 },
 playbtn() {
 let that = this;
 let mark = that.data.mark;
 if (mark){
  that.timer = setInterval(that.run, 1000); //that.timer關(guān)鍵點(diǎn)
  wx.showToast({
  title: '開(kāi)始',
  })
  that.setData({
  mark:false,
  playPausetips:"暫停"
  })
 }else{
  clearInterval(that.timer);
  wx.showToast({
  title: '暫停',
  })
  that.setData({
  mark: true,
  playPausetips: "開(kāi)始"
  })
 }
 },
 run(){
 let that = this;
 let totalProgressTime = 60 //秒
 let progressWidth = that.data.progressWidth; //顯示進(jìn)度
 let progressTime = that.data.progressTime; //時(shí)間
 
 if (progressWidth === 100) {
  wx.showToast({
  title: '結(jié)束回調(diào)處理',
  })
  clearInterval(that.timer);
  that.setData({
  progressTime: totalProgressTime, //進(jìn)度條需要總時(shí)間s
  progressWidth: 100, //進(jìn)度100%
  progressTime: 60
  })
  return;
 }
 progressTime--;
 progressWidth = (totalProgressTime - progressTime) * (100 / 60)
 that.setData({
  progressWidth: progressWidth,
  progressTime: progressTime
 })
 }
 
})

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

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

相關(guān)文章

最新評(píng)論