<view class="u-demo-block">
<text class="u-demo-block__title">可清空内容</text>
<view class="u-demo-block__content">
<u--input
ref="clearInput"
placeholder="请输入内容"
border="surround"
clearable
@confirm="contentConfirm"
@blur="contentBlur"
@focus="contentFocus"
v-model="content"
></u--input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">数字键盘</text>
<view class="u-demo-block__content">
<u--input
ref='numberInput'
placeholder="请输入内容"
@blur="numberBlur"
@focus="numberFocus"
border="surround"
type="number"
clearable
v-model="number"
></u--input>
</view>
</view>
methods: {
// 确认input框
contentConfirm(){
this.$refs['numberInput'].focus=true
// console.log(this.$refs['numberInput'].cursor,'cursor')
},
// 失焦
contentBlur(){
console.log('content失焦啦')
// this.$refs['clearInput'].focus=false
},
//聚焦
contentFocus(){
// this.$refs['clearInput'].focus=true
console.log('content聚焦啦')
},
//确认数字键盘框
numberConfirm(){
console.log('确认数字')
},
// 数字键盘失焦
numberBlur(){
// this.$refs['numberInput'].focus=false
console.log('number失焦啦')
},
// 数字键盘聚焦
numberFocus(){
// this.$refs['numberInput'].focus=true
console.log('number聚焦啦')
},
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);
}
}