forked from Spikef/vmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-button.vue
84 lines (75 loc) · 2.31 KB
/
v-button.vue
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
84
<template>
<span class="vmc-button" :class="[type, {disabled: disabled}]" :style="style">
<div class="block">
<slot name="icon-left"></slot>
<slot>{{text}}</slot>
<slot name="icon-right"></slot>
</div>
</span>
</template>
<script type="text/ecmascript-6">
import { getCSSSize } from '../../utils';
export default {
props: {
inline: Boolean,
radius: [Number, String],
height: [Number, String],
border: [Number, String],
width: [Number, String],
size: [Number, String],
disabled: Boolean,
text: {
type: String,
default: '确定'
},
type: {
type: String,
default: 'default',
validator(value) {
return [
'default',
'primary',
'success',
'info',
'danger',
'warning'
].indexOf(value) > -1;
}
},
colors: {
type: Object,
default() {
return null;
}
}
},
computed: {
style() {
var style = {
display: this.inline ? 'inline-block' : 'block'
};
if (this.height) {
style.height = getCSSSize(this.height);
}
if (this.width) {
style.width = getCSSSize(this.width);
}
if (this.border) {
style.borderWidth = getCSSSize(this.border);
}
if (this.radius) {
style.borderRadius = getCSSSize(this.radius);
}
if (this.size) {
style.fontSize = getCSSSize(this.size);
}
if (this.colors) {
style.color = this.colors.font;
style.borderColor = this.colors.border;
style.background = this.colors.background;
}
return style;
}
}
}
</script>