美文网首页
微信小程序 实现圆形进度条

微信小程序 实现圆形进度条

作者: 找不到工作的程序员 | 来源:发表于2020-07-03 14:46 被阅读0次

js

data: {
    animationData: {}
  },
onLoad: function (options) {
   
    setTimeout(() => {
      var animation = wx.createAnimation({
        duration: 1500,
        timingFunction: 'ease',
      })
  
      this.animation = animation
      animation.rotate(180).step()
  
      this.setData({
        animationData:animation.export()
      })
    }, 1000);
  },

在wxml

<view class="circle-wrap">
    <view class="circle">
      <view class="mask full">
        <view class="fill"></view>
      </view>
      <view class="mask half">
        <view class="fill" animation="{{animationData}}"></view>
      </view>
      <view class="inside-circle"> 70% </view>
    </view>
  </view>

在wxss

/*圆形css进度条*/
.circle-wrap {
  margin: 50px auto;
  width: 150px;
  height: 150px;
  background: #e6e2e7;
  border-radius: 50%;
}

.circle-wrap .circle .mask,
.circle-wrap .circle .fill {
  width: 150px;
  height: 150px;
  position: absolute;
  border-radius: 50%;
}

.circle-wrap .circle .mask {
  clip: rect(0px, 150px, 150px, 75px);
}

.circle-wrap .circle .mask .fill {
  clip: rect(0px, 75px, 150px, 0px);
  background-color: #9e00b1;
}



.circle-wrap .inside-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: #fff;
  line-height: 130px;
  text-align: center;
  margin-top: 10px;
  margin-left: 10px;
  position: absolute;
  z-index: 100;
  font-weight: 700;
  font-size: 2em;
}

相关文章

网友评论

      本文标题:微信小程序 实现圆形进度条

      本文链接:https://www.haomeiwen.com/subject/fjysqktx.html