验证码
<template>
<div
class="ValidCode disabled-select"
:style="`width:${width}; height:${height}`"
@click="refreshCode"
>
<span
v-for="(item,index) in codeList"
:key="index"
:style="getStyle(item)"
>{{item.code}}</span>
</div>
</template>
<script>
export default{
name:'ValidCode',
model:{
prop:'value',
event:'input'
},
props:{
width:{
type:String,
default:'100px'
},
height:{
type:String,
default:'40px'
},
length:{
type:Number,
default:4
},
refresh:{
type:Number
}
},
data(){
return{
codeList:[]
}
},
watch:{
refresh(){
this.createdCode()
}
},
mounted(){
this.createdCode()
},
methods: {
refreshCode() {
this.createdCode()
},
createdCode() {
const len = this.length
const codeList = []
const chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefghjkmnpqrstwxyz0123456789'
const charsLen = chars.length