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
74
75
76
77
78
79
80
81
82
83
| <template>
| <div class="switch-bar">
| <div class="name">{{ barName }}</div>
| <el-switch
| v-model="barValue"
| active-color="var(--colorCard)"
| :width="30"
| @change="switchChange"
| >
| </el-switch>
| </div>
| </template>
|
| <script>
| export default {
| name: "switchBar",
| props: ["barName", "value"],
| methods: {
| switchChange(val) {
| this.$emit("switchChange", val);
| },
| },
| computed: {
| barValue: {
| get() {
| return this.value;
| },
| set(newValue) {
| return newValue;
| },
| },
| },
| };
| </script>
| <style lang="scss">
| .switch-bar {
| display: flex;
| align-items: center;
| height: 50px;
| padding: 0 25px;
| justify-content: space-between;
| border-radius: 8px;
|
| margin-bottom: 4px;
| .el-switch.is-checked .el-switch__core::after {
| left: 100%;
| margin-left: -12px;
| }
|
| .el-switch__core {
| margin: 0;
| position: relative;
| width: 40px;
| height: 14px;
| border: 1px solid #dcdfe6;
| outline: 0;
| border-radius: 10px;
| -webkit-box-sizing: border-box;
| box-sizing: border-box;
| background: #dcdfe6;
| -webkit-transition: border-color 0.3s, background-color 0.3s;
| transition: border-color 0.3s, background-color 0.3s;
| vertical-align: middle;
| }
| .el-switch__core:after {
| content: "";
| position: absolute;
| top: 0px;
| left: 0px;
| border-radius: 100%;
| -webkit-transition: all 0.3s;
| transition: all 0.3s;
| width: 12px;
| height: 12px;
| background-color: #fff;
| }
| .name {
| font-size: 12px;
| color: #4f4f4f;
| font-weight: bold;
| }
| }
| </style>
|
|