TimeDown.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <svg class="containerrr">
  3. <circle
  4. class="progress" :style="'stroke-dashoffset:' + progress" cx="40" cy="40" r="33"
  5. fill="transparent" stroke="white" stroke-width="4" />
  6. <text class="ptext" x="40" y="40" fill="white" text-anchor="middle" alignment-baseline="middle">
  7. {{ maxs }}S
  8. </text>
  9. </svg>
  10. </template>
  11. <script>
  12. export default {
  13. components: {},
  14. data() {
  15. return {
  16. progress: 0,
  17. maxs: 120
  18. };
  19. },
  20. created() {
  21. this.timeout();
  22. },
  23. methods: {
  24. timeout() {
  25. var that = this;
  26. var p = 220 / that.maxs / 100;
  27. var t = 0;
  28. var daojishi = setInterval(() => {
  29. if (that.maxs > 0) {
  30. t = t + 1;
  31. that.progress = p * t;
  32. var yu = t % 100;
  33. if (yu == 0) {
  34. that.maxs--;
  35. }
  36. } else {
  37. clearInterval(daojishi);
  38. }
  39. }, 10);
  40. },
  41. },
  42. };
  43. </script>
  44. <style scoped lang="scss">
  45. .containerrr {
  46. position: absolute;
  47. top: 130px;
  48. right: 26px;
  49. z-index: 999;
  50. margin: auto;
  51. width: 80px;
  52. height: 80px;
  53. background: #2b0180;
  54. border-radius: 50%;
  55. }
  56. .progress {
  57. stroke-dasharray: 220, 9000;
  58. }
  59. .ptext {
  60. font-family: "阿里巴巴普惠体MEDIUM";
  61. font-size: 19px;
  62. }
  63. </style>