Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
captcha-slider
Advanced tools
滑块验证码是人类行为校验的一种,在当前需要登录的场景使用是相当频繁的。
commonjs
、esmoudle
和cdn
的方式引入npm install captcha-slider --save
import CaptchaSlider from 'captcha-slider'
提示: 也支持
<script src="captchaSlider.iife.js"></script>
的方式引入
添加html
容器
注意: 容器需要设置宽度,容器的宽度作为滑块验证码的宽度
<div class="captcha-slider" style="width: 360px;"></div>
new CaptchaSlider({
el: '.captcha-slider',
onSuccess () {
console.log('成功')
},
onFail () {
console.log('失败')
},
onChange (rate, event) {
console.log(rate, event)
}
})
名称 | 类型 | 默认值 | 必传 | 说明 |
---|---|---|---|---|
el | string | element | 无 | 是 | 控件容器 |
vailadeValue | number | 5 | 否 | 验证容错偏差值 默认5个像素偏差即认为验证通过 |
picList | string[] | 否 | 图片路径地址数组 | |
showReload | bookean | true | 否 | 是否显示右上角的额重新加载按钮 |
slideSizeRate | number | 0.1 | 否 | 滑块尺寸比率: 滑块实际尺寸 = 容器width * slideSizeRate |
vaildResultShowTime | number | 1500 | 否 | 验证结果展示事件 默认1500ms (单位ms) |
onSuccess | function | 无 | 否 | 验证成功时回调 (参数1:横向移动百分比) |
onFail | function | 无 | 否 | 验证失败时回调(参数1:横向移动百分比) |
onStart | function | 无 | 否 | 开始点击滑块时的回调(参数1:mousedown /touchstart 事件event ) |
onChange | function | 无 | 否 | 滑块滑动时的回调 (参数1: 横向移动百分比, 参数2:mousemove /touchmove 事件event ) |
onEnd | function | 无 | 否 | 滑块结束滑动时的回调 (参数1: 横向移动百分比, 参数2:mouseup /touchend 事件event ) |
方法名 | 返回值 | 示例 | 描述 |
---|---|---|---|
reset | 无 | captcha.reset() | 重置控件 |
loadNextImage | 无 | captcha.loadNextImage() | 使用下一个图片绘制控件 |
destory | 无 | captcha.destory() | 销毁控件 |
FAQs
We found that captcha-slider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.