一個基於原生JavaScript開發的、輕量的驗證碼生成插件 ...
Vcode.js
一個基於原生JavaScript開發的、輕量的驗證碼生成插件
V: 1.0.0
DEMO:https://jofunliang.github.io/Vcode.js/example.html
安裝
<script src="Vcode.min.js"></script>
OR
// ES6 Modules or TypeScript
import vcode from 'Vcode'
// CommonJS
const vcode = require('Vcode')
Support AMD/CMD/ES6 module standard.
使用示例
var vcode1 = new Vcode({
el:"#demo1 .code",
count:4,
fontSize:"60px",
type:"number",
spacing:0
});
參數
attribute | typeof | description |
---|---|---|
el | string | 必需,接受一個包含CSS選擇符的字元串,然後用它來匹配一個元素。 |
data | string | 可選,您可以自定義驗證碼的數據源。 |
count | number | 可選,驗證碼的長度,預設為4 |
type | string | 可選,驗證碼的類型,有三種模式,分別是數字模式、字母模式、數字字母隨機混合模式。預設是數字字母隨機混合模式 |
fontSize | string | 可選,驗證碼的字體大小。 |
spacing | string | 可選,驗證碼的字母間距。預設值為0 |
new Vcode對象的屬性和方法
property | typeof | description |
---|---|---|
el | object | 掛載元素。 |
code | string | 驗證碼。 |
data | string | 驗證碼的數據源。 |
count | number | 驗證碼的長度。 |
onReset | function | 重新生成新的驗證碼。 |
註:此插件在ie8和ie9瀏覽器上會降級顯示。