8
9
10 点击图形刷新
12确定
13 实现效果如下
点击会刷新随机生成指定位数的验证码
Math.floor 是对一个数字向下取整
charAt方法可返回指定位置的字符
toLowerCase() 把大写字母转换为小写字母
| 参数 | 说明 | 类型 | 默认值 |
| identifyCode | 需要展示的验证码 | string | 无 |
| 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 | 78 |
| contentHeight | 画布高度 | number | 34 |
代码
1 23 415 16 1815146 7 118 910点击图形刷新
12确定13
注:参考其他博主改动的