重构代码:更新滑块验证码组件

#Comment
对x轴禁止滑动
获取图片地址逻辑更改为先默认图床,再获取options.setSrc方法
This commit is contained in:
Argo Zhang 2019-03-14 15:25:45 +08:00
parent 7e8208d242
commit d2cb480c97
2 changed files with 6 additions and 5 deletions

View File

@ -147,8 +147,9 @@
img.setSrc();
}
img.setSrc = function () {
var src = 'https://picsum.photos/' + that.options.width + '/' + that.options.height + '/?image=' + Math.round(Math.random() * 20);
var src = '';
if ($.isFunction(that.options.setSrc)) src = that.options.setSrc();
if(!src || src === '') src = 'https://picsum.photos/' + that.options.width + '/' + that.options.height + '/?image=' + Math.round(Math.random() * 20);
if (isIE) { // IE浏览器无法通过img.crossOrigin跨域使用ajax获取图片blob然后转为dataURL显示
var xhr = new XMLHttpRequest()
xhr.onloadend = function (e) {

View File

@ -1,5 +1,5 @@
body {
overflow: hidden;
overflow-x: hidden;
}
.block {
@ -126,6 +126,6 @@ body {
transition: color .3s linear;
}
.refreshIcon:hover {
color: #6c757d;
}
.refreshIcon:hover {
color: #6c757d;
}