index.vue
992 Bytes
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
<template>
<view class="zui-button" hover-class="active" hover-start-time="70" hover-stay-time="150" :class="classRender" :style="style" @click="onClick">
<slot></slot>
</view>
</template>
<script>
export default {
name: 'zui-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'};` ;
},
classRender: function() {
return [this.size, this.disabled ? 'disabled' : '', this.block ? 'block' : '', this.type, this.round ? 'round' : '', this.square ? 'square' : ''];
}
},
methods: {
onClick: function() {
if (!this.disabled) {
this.$emit('click');
}
}
}
}
</script>
<style lang="scss">
@import "./index.scss";
</style>