Skip to content

Commit 89bdbb5

Browse files
authored
Update README.md
1 parent 7dd09a1 commit 89bdbb5

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,88 @@
11
# react-vcode
2-
a react component with verification code
2+
3+
一个简单的React验证码组件
4+
5+
## 1. 安装
6+
7+
````
8+
npm install react-luo
9+
````
10+
11+
## 2. 使用
12+
13+
````
14+
import Vcode from 'react-luo';
15+
16+
<Vcode />
17+
18+
````
19+
20+
# 3. 自定义参数
21+
22+
可自行设置覆盖原有值
23+
24+
````
25+
id             # string 一个ID 可手动设置也可以不管,默认值:时间戳+随机数
26+
length: 4         # number 生成几位验证码
27+
width: 150          # number 容器宽度
28+
height: 40         # number  容器高度
29+
className       # string  自定义样式class, 默认值:无
30+
onChange           # func    生成新的验证码时触发,将新的验证码字符串返回上级
31+
style: {           # object 容器样式 (注:如果在style中设置width和height,将覆盖上面通过属性设置的width和height)
32+
 position: 'relative',
33+
backgroundColor: '#fff',
34+
overflow: 'hidden',
35+
cursor: 'pointer',
36+
verticalAlign: 'middle',
37+
userSelect: 'none',
38+
}
39+
options:{           # 自定义参数
40+
 codes: [          # 所有可能出现的字符
41+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
42+
'o', 'p', 'q', 'r', 's', 't', 'x', 'u', 'v', 'y', 'z', 'w', 'n',
43+
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
44+
],
45+
 fontSizeMin: 22, # 字体尺寸最小值
46+
 fontSizeMax: 26, # 字体尺寸最大值
47+
 colors: [         # 字可能的颜色
48+
'117cb3',
49+
'f47b06',
50+
'#202890',
51+
'#db1821',
52+
'#b812c2',
53+
],
54+
 fonts: [         # 可能的字体
55+
'Times New Roman',
56+
'Georgia',
57+
'Serif',
58+
'sans-serif',
59+
'arial',
60+
'tahoma',
61+
'Hiragino Sans GB',
62+
],
63+
 lines: 8,         # 生成多少根干扰线
64+
 lineColors: [     # 线可能的颜色
65+
'#7999e1',
66+
'#383838',
67+
'#ec856d',
68+
'#008888',
69+
],
70+
 lineHeightMin: 1, # 线的粗细最小值
71+
 lineHeightMax: 1, # 线的粗细最大值
72+
 lineWidthMin: 20, # 线的长度最小值
73+
 lineWidthMax: 60, # 线的长度最大值
74+
}
75+
76+
# 例子:
77+
78+
<Vcode
79+
 id='test'
80+
length={6}
81+
 onChange={(v) => {console.log('当前的验证码值:', v)}}
82+
 options={{ codes: [ 'A', 'B', 'C' ] }}
83+
/>
84+
````
85+
86+
## 4. 额外说明
87+
88+
* 之前用过一个验证码插件叫 vcode.js, 不知道作者。 本react-vcode是通过vcode.js的源码进行修改加工,转成了react组件。感谢愿作者。

0 commit comments

Comments
 (0)