vue3-captcha
Version:
a canvas captcha built in Vue3 with TypeScript
48 lines (39 loc) • 1.08 kB
Markdown
A canvas captcha built in Vue3 with TypeScript
```js
npm i -S vue3-captcha
````
```js
<script setup lang="ts">
import {ref} from "vue"
import Captcha,{CaptchaInstance} from 'vue3-captcha';
let value=ref('')
let refCode=ref<CaptchaInstance>(null)
const handleCheck=()=>{
if(refCode.value?.check(value.value)){
console.log("check success")
}
}
</script>
<template>
<Captcha ref="refCode" />
<input v-model="value">
<button @click="handleCheck">校验</button>
</template>
```
| attr | type | default | remark |
|-------|------|---------|---------|
| width | Number\|String |120| width|
| height | Number\|String |40| height|
| borderColor | String |rgba(0,0,0,0.1)| border-color|
| bgColor | String |
| clickRefresh | Boolean |true| click refresh|
| failRefresh | Boolean |false| verification failed, refresh|
| method | params | return | remark |
|----------|--------|--------|--------|
| refresh | | void | refresh |
| check | value | true/false |verification value|