zydx-plus 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="switch" :style="{
|
|
3
|
+
width: width + 'px',
|
|
4
|
+
height: height + 'px',
|
|
5
|
+
'background-color': (roundValue)? backColor: '#ccc'}">
|
|
6
|
+
<label class="round" :style="{
|
|
7
|
+
transform: 'translateX('+ trans +'px)',
|
|
8
|
+
width: (height - 4) + 'px',
|
|
9
|
+
height: (height - 4) + 'px'}">
|
|
10
|
+
<input type="checkbox" name="box" @click="submit" v-model="roundValue" />
|
|
11
|
+
<span></span>
|
|
12
|
+
</label>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
name: "zydx-switch",
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
trans: 0,
|
|
22
|
+
roundValue: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
width: { // 宽度
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 50
|
|
29
|
+
},
|
|
30
|
+
height: { // 高度
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 25
|
|
33
|
+
},
|
|
34
|
+
backColor: { // 开关背景颜色
|
|
35
|
+
type: String,
|
|
36
|
+
default: '#13ce66'
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
submit() {
|
|
41
|
+
if(this.roundValue) {
|
|
42
|
+
this.trans = 0
|
|
43
|
+
}else {
|
|
44
|
+
this.trans = this.width - this.height
|
|
45
|
+
}
|
|
46
|
+
this.$emit('submit', !this.roundValue)
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.switch{
|
|
54
|
+
border-radius: 20px;
|
|
55
|
+
background-color: #ccc;
|
|
56
|
+
position: relative;
|
|
57
|
+
}
|
|
58
|
+
.round{
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 2px;
|
|
61
|
+
left: 2px;
|
|
62
|
+
z-index: 1;
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
background-color: #fff;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
transition-duration: 200ms;
|
|
67
|
+
display: inline-block;
|
|
68
|
+
}
|
|
69
|
+
.round span{
|
|
70
|
+
display: inline-block;
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
}
|
|
74
|
+
input[name="box"] {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
</style>
|
package/src/index.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Message from './components/tipBox/index';
|
|
2
2
|
import Calendar from './components/calendar/index';
|
|
3
|
+
import Switch from './components/switch/index';
|
|
3
4
|
|
|
4
5
|
const components = [
|
|
5
|
-
Calendar
|
|
6
|
+
Calendar,
|
|
7
|
+
Switch
|
|
6
8
|
];
|
|
7
9
|
|
|
8
10
|
function install(app) {
|
|
9
11
|
components.forEach(component => {
|
|
10
12
|
app.component(component.name, component);
|
|
11
13
|
});
|
|
12
|
-
app.config.globalProperties.$message =
|
|
14
|
+
app.config.globalProperties.$message = Message
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export default {
|
|
16
|
-
version: '1.0.
|
|
18
|
+
version: '1.0.8',
|
|
17
19
|
install,
|
|
18
|
-
Calendar
|
|
20
|
+
Calendar,
|
|
21
|
+
Message,
|
|
22
|
+
Switch
|
|
19
23
|
};
|
|
20
24
|
|