 按钮进度条
          按钮进度条
        
  原理:画两个大小一致的按钮进行叠加,上层按钮父级宽度设置为当前进度,超出隐藏。
正在下载…
 正在下载…
正在下载…
 正在下载…
<template>
  <div class="demo-ProgressButton">
    <div class="btn-container">
      <div class="btn">{{text}}</div>
      <div class="progress-container" style="width: 59%;">
        <div class="btn">{{text}}</div>
      </div>
    </div>
    <div class="btn-container">
      <div class="btn">{{text}}</div>
      <div class="progress-container animation">
        <div class="btn">{{text}}</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'ProgressButton',
  data() {
    return {
      text: '正在下载…',
    }
  }
}
</script>
<style lang="scss">
.demo-ProgressButton {
  .btn-container {
    margin: 20px;
    position: relative;
    width: 288px;
    height: 44px;
  }
  .btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
		font-size: 22px;
		letter-spacing: 4px;
		font-weight: bold;
    background-color: rgba(#f2571e, .2);
    color: #f35a20;
  }
  .progress-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    overflow: hidden;
    z-index: 1;
    &.animation {
      transition: width 100ms linear;
      animation: widthProgress 2s linear infinite normal;
    }
    .btn {
      width: 288px;
      height: 44px;
      background-color: #f2571e;
      color: #fff;
    }
  }
  @keyframes widthProgress {
    to {
      width: 100%;
    }
  }
}
</style>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
上次更新: 2021-07-08 10:53:30