Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a18cbf4

Browse filesBrowse files
committed
update
1 parent dc20979 commit a18cbf4
Copy full SHA for a18cbf4

File tree

3 files changed

+43
-25
lines changed
Filter options

3 files changed

+43
-25
lines changed

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ typings/
5959

6060
# next.js build output
6161
.next
62-
*.lock
62+
*.lock
63+
64+
dist/

‎README.md

Copy file name to clipboardExpand all lines: README.md
+40-23Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ Vue 纯前端的拼图人机验证、右滑拼图验证<br/> 我知道有第 3
77

88
![img](public/demo.gif)
99

10-
## 重要更新
11-
12-
2020/03/16 v1.1.0 **事件名改变** <br/>
13-
14-
```
15-
@onSuccess -> @success
16-
@onClose -> @close
17-
@onFail -> @fail
18-
```
1910

2011
### 安装
2112

@@ -28,7 +19,7 @@ Vue 纯前端的拼图人机验证、右滑拼图验证<br/> 我知道有第 3
2819
```vue
2920
import Vcode from "vue-puzzle-vcode";
3021
31-
<Vcode :show="isShow" @success="success" @close="close" />
22+
<Vcode :show="isShow" @success="onSuccess" @close="onClose" />
3223
```
3324

3425
### IE
@@ -38,12 +29,12 @@ import Vcode from "vue-puzzle-vcode";
3829
到自己的项目里,给`app.vue`随便改个名字,就是个普通 vue 组件,直接用即可。<br/>
3930
`src/assets`里是一张小图片,`app.vue`中有引用,注意自己匹配一下引用路径
4031

41-
### 最简单例子
32+
### Vue2.0 最简单例子
4233

4334
```vue
4435
<template>
4536
<div>
46-
<Vcode :show="isShow" @success="success" @close="close" />
37+
<Vcode :show="isShow" @success="onSuccess" @close="onClose" />
4738
<button @click="submit">开始验证</button>
4839
</div>
4940
</template>
@@ -53,7 +44,7 @@ import Vcode from "vue-puzzle-vcode";
5344
export default {
5445
data() {
5546
return {
56-
isShow: false, // 验证码模态框是否出现
47+
isShow: false,
5748
};
5849
},
5950
components: {
@@ -63,12 +54,12 @@ export default {
6354
submit() {
6455
this.isShow = true;
6556
},
66-
// 用户通过了验证
67-
success(msg) {
57+
58+
onSuccess(msg) {
6859
this.isShow = false; // 通过验证后,需要手动关闭模态框
6960
},
70-
// 用户点击遮罩层,应该关闭模态框
71-
close() {
61+
62+
onClose() {
7263
this.isShow = false;
7364
},
7465
},
@@ -124,19 +115,19 @@ export default {
124115
- 也可以是网络图片完整 URL 路径,但注意图片跨域问题,因为 canvas api 无法调用跨
125116
域的图片
126117

127-
### 说明
128118

129-
- 当不传递 imgs 字段或图片加载出错时,会自动生成随机图片
130-
- 模态框的显示和隐藏完全由父级控制,所以用户通过验证后,需要手动隐藏模态框
119+
<br/><br/>
120+
---
131121

132-
## 使用 Vue3.0
122+
# 使用 Vue3.0
123+
<br/>
133124

134125
### 安装 vue3-puzzle-vcode
135126
```node
136127
npm install vue3-puzzle-vcode --save
137128
```
138129

139-
### 最简单例子
130+
### Vue3.0 最简单例子
140131
```vue
141132
<template>
142133
<button @click="onShow">开始验证</button>
@@ -176,4 +167,30 @@ export default {
176167
</script>
177168
```
178169

179-
- 其他都更vue2.0一样
170+
### Vue3.0 自定义图片
171+
```vue
172+
<template>
173+
<Vcode :imgs="imgs" />
174+
</template>
175+
176+
<script>
177+
import Img1 from "~/assets/img1.png";
178+
import Img2 from "~/assets/img2.png";
179+
180+
export default {
181+
setup(){
182+
const imgs = [Img1, Img2];
183+
184+
return {
185+
imgs
186+
}
187+
}
188+
};
189+
</script>
190+
```
191+
- 其他参数/事件都更vue2.0一样
192+
193+
### 说明
194+
195+
- 当不传递 imgs 字段或图片加载出错时,会自动生成随机图片
196+
- 模态框的显示和隐藏完全由父级控制,所以用户通过验证后,需要手动隐藏模态框

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.