test.vue
4.75 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础使用</text>
<view class="u-demo-block__content">
<u--input
placeholder="请输入内容"
border="surround"
v-model="value"
@change="change"
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">可清空内容</text>
<view class="u-demo-block__content">
<u--input
placeholder="请输入内容"
border="surround"
clearable
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">数字键盘</text>
<view class="u-demo-block__content">
<u--input
placeholder="请输入内容"
border="surround"
type="number"
clearable
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">密码类型</text>
<view class="u-demo-block__content">
<u--input
placeholder="请输入内容"
border="surround"
password
clearable
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">显示下划线</text>
<view class="u-demo-block__content">
<u--input
placeholder="请输入内容"
border="bottom"
clearable
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">禁用状态</text>
<view class="u-demo-block__content">
<u--input
placeholder="禁用状态"
border="surround"
disabled
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">圆形</text>
<view class="u-demo-block__content">
<u--input
placeholder="请输入内容"
border="surround"
shape="circle"
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">前后图标</text>
<view class="u-demo-block__content">
<u--input
placeholder="前置图标"
prefixIcon="search"
prefixIconStyle="font-size: 22px;color: #909399"
></u--input>
</view>
<view
class="u-demo-block__content"
style="margin-top: 15px;"
>
<u--input
placeholder="后置图标"
suffixIcon="map-fill"
suffixIconStyle="color: #909399"
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">前后插槽</text>
<view class="u-demo-block__content">
<!-- 注意:由于兼容性差异,如果需要使用前后插槽,nvue下需使用u--input,非nvue下需使用u-input -->
<!-- #ifndef APP-NVUE -->
<u-input placeholder="前置插槽">
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<u--input placeholder="前置插槽">
<!-- #endif -->
<u--text
text="http://"
slot="prefix"
margin="0 3px 0 0"
type="tips"
></u--text>
<!-- #ifndef APP-NVUE -->
</u-input>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
</u--input>
<!-- #endif -->
</view>
<view
class="u-demo-block__content"
style="margin-top: 15px;"
>
<!-- 注意:由于兼容性差异,如果需要使用前后插槽,nvue下需使用u--input,非nvue下需使用u-input -->
<!-- #ifndef APP-NVUE -->
<u-input placeholder="后置插槽">
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<u--input placeholder="后置插槽">
<!-- #endif -->
<template slot="suffix">
<u-code
ref="uCode"
@change="codeChange"
seconds="20"
changeText="X秒重新获取哈哈哈"
></u-code>
<u-button
@tap="getCode"
:text="tips"
type="success"
size="mini"
></u-button>
</template>
<!-- #ifndef APP-NVUE -->
</u-input>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
</u--input>
<!-- #endif -->
</view>
</view>
<u-gap
bgColor="#fff"
height="50"
></u-gap>
</view>
</template>
<script>
export default {
data() {
return {
tips: '',
value: ''
}
},
watch: {
value(newValue, oldValue) {
// console.log('v-model', newValue);
}
},
methods: {
codeChange(text) {
this.tips = text;
},
getCode() {
if (this.$refs.uCode.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: '正在获取验证码'
})
setTimeout(() => {
uni.hideLoading();
// 这里此提示会被this.start()方法中的提示覆盖
uni.$u.toast('验证码已发送');
// 通知验证码组件内部开始倒计时
this.$refs.uCode.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
}
},
change(e) {
console.log('change', e);
}
}
}
</script>
<style lang="scss">
</style>