APICloud AVM框架封装验证码输入框组件

简介: APICloud AVM框架封装验证码输入框组件实例。验证码输入框组件,可自定义下次点击等待时长,自定义验证码长度,可根据自定义的验证码长度进行输入内容的验证。

APICloud AVM框架封装验证码输入框组件实例。

验证码输入框组件,可自定义下次点击等待时长,自定义验证码长度,可根据自定义的验证码长度进行输入内容的验证。

组件引用

import '../../components/verification-code-input.stml'

组件使用

组件文件

verification-code-input.stml

获取验证码

{count}s

export default {

name: 'verification-code-input',

installed(){

},

props:{

limitSecond:Number,

limitCode:Number

},

data() {

return{

show:true,

count: 0,

timer:null

}

},

methods: {

sendCode(){

//正则验证手机号码

const TIME_COUNT = this.props.limitSecond;

if (!this.data.timer) {

this.data.count = TIME_COUNT;

this.data.show = false;

this.data.timer = setInterval(() => {

if (this.data.count > 0 && this.data.count <= TIME_COUNT) {

this.data.count--;

} else {

this.data.show = true;

clearInterval(this.data.timer);

this.data.timer = null;

}

}, 1000)

}

/**

  • 进行发送短信验证码的操作

*/

},

getCode(e){

//对验证码进行校验 符合位置和规则进行输出

if(e.detail.value.length == this.props.limitCode){

let reg= /^[0-9]*$/;

if(reg.test(e.detail.value)){

this.fire('setCode',e.detail.value);

}

else{

api.toast({

msg:'请输入有效的验证码!'

})

}

}

else if(e.detail.value.length > this.props.limitCode){

api.toast({

msg:'请输入'+this.props.limitCode+"位验证码!"

})

}

}

}

}

.verification-code{

flex-flow: row nowrap;

margin: 10px 20px;

justify-content: space-between;

border-bottom: 0.5px solid #f0f0f0;

align-items: center;

}

.code-input{

width: auto;

border: none;

font-size: 18px;

}

.code-btn{

color: #1492ff;

font-size: 18px;

}

组件使用示例

import '../../components/verification-code-input.stml'

export default {

name: 'demo-verification-code-input',

apiready(){

},

data() {

return{

code:'',

seconds:60,

codeLen:4

}

},

methods: {

getCode(e){

console.log(JSON.stringify(e.detail));

this.data.code = e.detail;

}

}

}

.page {

height: 100%;

background-color: #ffffff;

padding-top: 100px;

}

.verification-code{

flex-flow: row nowrap;

margin: 10px 20px;

justify-content: space-between;

border-bottom: 0.5px solid #f0f0f0;

align-items: center;

}

.code-input{

width: auto;

border: none;

font-size: 15px;

flex: 1;

}

.code-btn{

color: #1492ff;

font-size: 15px;

}

目录
相关文章
|
运维 监控 安全
DevSecOps:打造安全无忧的DevOps流程
在现代软件开发中,保证安全性和敏捷性的平衡成为了一项重要任务。DevSecOps(Development-Security-Operations)作为一种实践方法,旨在将安全性与DevOps流程相结合,从而提供持续且可靠的软件交付。本文将介绍DevSecOps的核心概念和原则,并探讨如何将安全融入到DevOps流程中,以确保软件开发过程中的安全性。
|
2天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8078 2
|
11天前
|
域名解析 人工智能 Linux
|
19天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
10271 13
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
5天前
|
人工智能 安全 网络安全
|
10天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是 DeepSeek AI 开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、执行命令、处理表格等自动化任务;免费开源,兼容 Win/macOS,需配 API 密钥使用。(239字)
1547 5
|
9天前
|
云安全 数据采集 人工智能
|
16天前
|
人工智能 开发工具 开发者
2026最新codex下载安装保姆级使用教程(下载+安装+登录+使用,含所有历史版本)
Codex 是 OpenAI 推出的开源 AI 编程智能体,跑在本地终端和桌面客户端里,能读懂整个代码仓库,一句自然语言就能让它改代码、执行命令、跑测试、修 Bug,支持 Windows、macOS、Linux 三大平台。本文把 Codex下载、安装、登录、汉化、基础使用一次讲全,并整理了国内用户最常踩的坑,跟着做 10 分钟就能跑起来。
2698 8