验证码组件
创建一个验证码的vue组件
将下列代码复制到主机中在其他页面引入
identifyCode为验证码,传入字符串即可
<template>
<div class="s-canvas">
<canvas id="s-canvas" :width="contentWidth" :height="contentHeight"></canvas>
</div>
</template>
<script>
export default {
name: 'identify',
props: {
identifyCode: {
//默认注册码
type: String,
default: '1234'
},
fontSizeMin: {
// 字体最小值
type: Number,
default: 25
},
fontSizeMax: {
// 字体最大值
type: Number,
default: 35
},
backgroundColorMin: {
// 验证码图片背景色最小值
type: Number,
default: 200
},
backgroundColorMax: {
// 验证码图片背景色最大值
type: Number,
default: 220
},
dotColorMin: {
// 背景干扰点最小值
type: Number,
default: 60
},
dotColorMax: {
// 背景干扰点最大值
type: Number,
default: 120