Giter VIP home page Giter VIP logo

identify's Introduction

identify(生成验证码图片)

  • This is a digital graphic verification code written in canvas
  • 这是一个vue的插件,使用canvas来生成图形验证码

Attributes

参数 说明 类型 默认值
identifyCode 需要展示的验证码 string 1234
fontSizeMin 字体大小,最小值 number 16
fontSizeMax 字体大小,最大值 number 40
backgroundColorMin 背景颜色色值最小值,最小为0 number 180
backgroundColorMax 背景颜色色值最大值,最大为255 number 240
colorMin 字体颜色色值最小值,最小为0 number 50
colorMax 字体颜色色值最大值,最大为255 number 160
lineColorMin 干扰线颜色色值最小值,最小为0 number 40
lineColorMax 干扰线颜色色值最大值,最大为255 number 180
dotColorMin 干扰点颜色色值最小值,最小为0 number 0
dotColorMax 干扰点颜色色值最大值,最大为255 number 255
contentWidth 画布宽度 number 160
contentHeight 画布高度 number 40

Demo

<template>
  <div id="app">
    <s-identify :identifyCode="identifyCode"></s-identify>
    <button @click="refreshCode">看不清,换一张验证码</button>
  </div>
</template>

<script>

export default {
  name: 'app',
  data () {
    return {
      identifyCodes: '1234567890',
      identifyCode: ''
    }
  },
  methods: {
    // 生成一个随机数
    randomNum (min, max) {
      return Math.floor(Math.random() * (max - min) + min)
    },
    refreshCode () {
      this.identifyCode = ''
      this.makeCode(this.identifyCodes, 4)
    },
    makeCode (o, l) {
      for (let i = 0; i < l; i++) {
        this.identifyCode += this.identifyCodes[this.randomNum(0, this.identifyCodes.length)]
      }
    }
  },
  mounted () {
    this.identifyCode = ''
    this.makeCode(this.identifyCodes, 4)
  }
}
</script>


Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

npm test

identify's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

identify's Issues

干扰线和干扰颜色

这个验证码插件好用多了,可配置也非常好,就是这个干扰线和干扰颜色感觉调节不了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.