Vue中使用 captcha.min.js 做验证码

1 verificationCode() {
2       let captcha1 = new CaptchaMini()
3       captcha1.draw(document.querySelector('#captcha1'), r => {
4         this.Verification = r
5       })
6  },

先在要用的组件中引入 

import CaptchaMini from '../../static/js/captcha.min.js'
 
然后写一个容器放验证码:
<canvas class="canvas_v" width="100" height="50" id="captcha1"></canvas>
 
最后把上面的代码在加载完dom后执行就可以了(
this.Verification写你自己的变量
 
captcha.min.js地址:https://blog-static.cnblogs.com/files/lyt520/captcha.min.js
posted @ 2020-11-09 10:07  yw3692582  阅读(1324)  评论(0编辑  收藏  举报