vue-validate-code
v0.1.0
Published
Vue validate code
Maintainers
Readme
vue-validate-code
Install
npm i vue-validate-codeyarn add vue-validate-codepnpm add vue-validate-codeUsage
<script lang="ts" setup>
import { useTemplateRef } from 'vue'
import { ValidateCode } from 'vue-validate-code'
const validateCode = ref('')
const validateCodeRef = useTemplateRef('validateCodeRef')
function handleTriggerValidate() {
if (!validateCode.value) {
return console.log('No validate code value')
}
validateCodeRef.value?.validate(validateCode.value)
}
function handleValidateCallback(isValid) {
if (isValid) {
console.log('validate success')
} else {
console.log('validate fail')
validateCodeRef.value?.update()
}
}
</script>
<template>
<ValidateCode
@validate="handleValidateCallback"
ref="validateCodeRef"
renderer="svg"
/>
<input
v-model="validateCode"
placeholder="Fill the validate code"
/>
<button
@click="handleTriggerValidate"
type="button"
>
Validate
</button>
</template>Renderer
ValidateCode supports two built-in renderers:
canvas(default)svg
<ValidateCode renderer="canvas" />
<ValidateCode renderer="svg" />Docs
Check more examples and APIs in Docs
