login.vue
1.51 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<template>
<div>
<!-- <van-password-input
:value="value"
info="密码为6位数字"
@focus="keyboard = 'custom'"
/> -->
<van-field v-model="value" :maxlength="10" @click.native="keyboard = 'custom'" @blur="onBlur" readonly placeholder="请输入用户名" />
<!-- <van-number-keyboard
:show="showKeyboard"
@input="onInput"
@delete="onDelete"
@blur="showKeyboard = false"
/> -->
<van-number-keyboard
:show="keyboard === 'custom'"
close-button-text="完成"
theme="custom"
extra-key="."
@blur="keyboard = ''"
@input="onInput"
@delete="onDelete"
@close="onClose"
/>
</div>
</template>
<script>
export default {
data () {
return {
value: '',
showKeyboard: true,
keyboard: 'default'
}
},
methods: {
onInput (key) {
this.value = (this.value + key).slice(0, 5)
},
onDelete () {
this.value = this.value.slice(0, this.value.length - 1)
},
onBlur () {
// console.warn(this.value);
},
onClose () {
this.keyboard = false
}
}
}
</script>
<style lang="less" scoped>
.login {
position: absolute;
top: 25%;
left: 50%;
transform: translateX(-50%);
padding: 1.8rem 2.5rem;
width: 15rem;
button {
margin-top: 1.2rem;
position: absolute;
right: 2.5rem;
}
input {
display: block;
width: 95%;
padding: 0.8rem 0.4rem;
background: #fff;
border: 1px solid #d6d7dc;
font-size: 0.95rem;
}
}
</style>