CSS: 使用 svg 实现圆形进度条

CSS: 使用 svg 实现圆形进度条,第1张

使用 Vue 框架进行实现

<template>
  <div class="mhy-audio-player" @click="onClickAudio">
    <div  class="mhy-audio-player__svg">
      <svg xmlns="http://www.w3.org/2000/svg"
           xmlns:xlink="http://www.w3.org/1999/xlink"
           width="24"
           height="24"
           viewBox="0 0 26 26"
           preserveAspectRatio="xMinYMin meet"
      >
        <circle
          cx="13" cy="13" r="12"
          class="mhy-audio-player__circle1"
        />
        <circle
          cx="13" cy="13" r="12"
          class="mhy-audio-player__circle"
          stroke-dasharray="75"
          :stroke-dashoffset="dashoffset"/>
      svg>
    div>
    <div class="mhy-audio-player__status">
      <div
        v-if="isPlay"
        class="mhy-audio-player__status--play">
        <span>span>
        <span>span>
      div>
      <div
        v-else
        class="mhy-audio-player__status--pause">
        <mhy-icon name="select_arrow"/>
      div>
    div>
  div>
template>


<script>
  export default {
    name: 'mhy-audio-player',
    data() {
      return {
        isPlay: false,
        process: 0
      };
    },
    computed: {
      dashoffset() {
        return 75 * (1 - this.process);
      }
    },
    methods: {
      onClickAudio() {
        setInterval(() => {
          this.process += 0.01;
        }, 15);
        this.isPlay = !this.isPlay;
      }
    }
  };
</script>




欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1321556.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-12
下一篇2022-06-12

发表评论

登录后才能评论

评论列表(0条)

    保存