button2.vue
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
57
58
59
60
61
62
<template>
<button class="btn" :class="classes" type="button" @touchstart="onTouchstart" @touchend.prevent.stop="onTouchend">
<span>
<slot></slot>
</span>
</button>
</template>
<script>
export default {
name: 'Button',
data() {
return {
classes: {}
};
},
methods: {
onTouchstart() {
this.classes = {
active: true
};
},
onTouchend() {
this.clearActive();
this.$emit('click');
},
clearActive() {
this.classes = {};
}
}
};
</script>
<style lang="scss">
.btn {
display: inline-block;
margin-bottom: 0;
font-weight: normal;
text-align: center;
vertical-align: middle;
touch-action: none;
background: none;
white-space: nowrap;
line-height: 1.5;
user-select: none;
font-size: 30px;
outline: 0;
border: none;
color: #000;
background-color: #eee;
height: 60px;
padding-left: 40px;
padding-right: 40px;
&:active,
&.active {
opacity: 0.5;
// color: #eee !important;
}
}
</style>