Skip to content

Commit e4e6d04

Browse files
author
En
committed
doc
1 parent dd69a2e commit e4e6d04

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

README.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,18 @@
1818

1919
## Introduction 介绍
2020

21-
获取短信验证码的 vue 组件(封装了发送验证码、倒计时,倒计时完成后可以重新发送……)。
22-
23-
非常简单,用起来很方便,非常灵活,支持复杂的场景。
21+
vue-get-code 封装了发送验证码、倒计时,倒计时完成后可以重新发送……
2422

23+
使用很简单,支持灵活的配置,支持复杂的场景。
2524
获取短信验证码、获取邮件验证码,都可以使用这个组件。
2625

27-
## Features 特点
28-
29-
vue-get-code 是一个非常灵活的获取短信验证码组件。
30-
31-
支持灵活的配置:
32-
33-
- 倒计时的秒数,默认 60 秒,可按需设置
34-
- 发送验证码需要 ajax 调用接口,可以在 getCode() 函数中实现,过程由开发者实现,非常灵活,返回一个 Promise 对象即可,组件会等待函数,成功后会开始倒计时,失败了会结束倒计时。在此函数中,也可以做表单验证,真的非常灵活。
35-
- 调用者可以控制组件是否禁用
36-
- 发送验证码前、倒计时、禁用,多个状态都有对应 class,控制样式非常方便
37-
- 可以定制发验证码之前的文字
38-
- 可以定制倒计时的文案
39-
- 倒计时有事件触发(countdownBegin/countdownUpdate/countdownEnd)
40-
- 获取验证码接口报错有事件触发(getCodeError)
41-
42-
## Install 安装
43-
44-
`npm install vue-get-code`
45-
46-
## Usage 使用
47-
48-
### 基本用法
26+
快速使用:
4927

5028
```vue
5129
<template>
5230
<form>
53-
<input placeholder="phone" />
54-
<vue-get-code :getCode="getCode" />
31+
<input placeholder="phone" value="130xxxx" />
32+
<vue-get-code :getCode="getCode"></vue-get-code>
5533
</form>
5634
</template>
5735
@@ -83,13 +61,34 @@ export default {
8361
</style>
8462
```
8563

64+
## Features 特点
65+
66+
vue-get-code 是一个非常灵活的获取短信验证码组件。
67+
68+
支持灵活的配置:
69+
70+
- 倒计时的秒数,默认 60 秒,可按需设置
71+
- 发送验证码需要 ajax 调用接口,可以在 getCode() 函数中实现,过程由开发者实现,非常灵活,返回一个 Promise 对象即可,组件会等待函数,成功后会开始倒计时,失败了会结束倒计时。在此函数中,也可以做表单验证,真的非常灵活。
72+
- 调用者可以控制组件是否禁用
73+
- 发送验证码前、倒计时、禁用,多个状态都有对应 class,控制样式非常方便
74+
- 可以定制发验证码之前的文字
75+
- 可以定制倒计时的文案
76+
- 倒计时有事件触发(countdownBegin/countdownUpdate/countdownEnd)
77+
- 获取验证码接口报错有事件触发(getCodeError)
78+
79+
## Install 安装
80+
81+
`npm install vue-get-code`
82+
83+
## Usage 使用
84+
8685
### 修改配置,把倒计时改为 120 秒
8786

8887
```vue
8988
<template>
9089
<form>
91-
<input placeholder="phone" />
92-
<vue-get-code :getCode="getCode" :interval="120" />
90+
<input placeholder="phone" value="130xxxx" />
91+
<vue-get-code :getCode="getCode" :interval="120"></vue-get-code>
9392
</form>
9493
</template>
9594
@@ -149,7 +148,7 @@ getCodeError
149148
```vue
150149
<template>
151150
<form>
152-
<input placeholder="phone" />
151+
<input placeholder="phone" value="130xxxx" />
153152
<vue-get-code :getCode="getCode" :interval="3">
154153
<template v-slot:default="child">
155154
{{ child.data.count <= 0 ? '获取验证码' : '重新获取' }}

docs/basic.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
```vue
44
<template>
55
<form>
6-
<input placeholder="phone">
7-
<vue-get-code :getCode="getCode"/>
6+
<input placeholder="phone" value="130xxxx" />
7+
<vue-get-code :getCode="getCode"></vue-get-code>
88
</form>
99
</template>
1010
@@ -38,8 +38,8 @@ export default {
3838
```vue
3939
<template>
4040
<form>
41-
<input placeholder="phone">
42-
<vue-get-code :getCode="getCode" :interval="120" />
41+
<input placeholder="phone" value="130xxxx" />
42+
<vue-get-code :getCode="getCode" :interval="120"></vue-get-code>
4343
</form>
4444
</template>
4545
@@ -72,7 +72,7 @@ export default {
7272
```vue
7373
<template>
7474
<form>
75-
<input placeholder="phone">
75+
<input placeholder="phone" value="130xxxx" />
7676
<vue-get-code :getCode="getCode" :interval="3">
7777
<template v-slot:default="child">
7878
{{ child.data.count <= 0 ? '获取验证码' : '重新获取' }}

0 commit comments

Comments
 (0)