index.vue
1.1 KB
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
<template>
<div class="zui-button" :class="classRender" :style="style" @click="onClick">
<slot></slot>
</div>
</template>
<script>
export default {
name: 'Button',
props: {
type: {
type: String,
default: 'default',
},
size: {
type: String,
default: 'md',
},
block: {
type: Boolean,
default: false,
},
round: Boolean,
square: Boolean,
disabled: Boolean,
},
computed: {
style: function () {
return { display: this.block ? '' : 'inline-block', borderRadius: this.borderRadius };
},
borderRadius: function () {
if (this.round) {
return '1.25rem';
} else if (this.square) {
return '0';
} else {
return '0.25rem';
}
},
classRender: function () {
return [this.size, this.disabled ? 'disabled' : '', this.block ? 'block' : '', this.type];
},
},
methods: {
onClick: function () {
if (this.$listeners['click'] && !this.disabled) {
this.$emit('click');
}
},
},
};
</script>
<style lang="scss">
@import './index.scss';
</style>