最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue 登錄滑動(dòng)驗(yàn)證實(shí)現(xiàn)代碼

 更新時(shí)間:2018年08月24日 10:03:08   作者:前端小白16  
這篇文章主要介紹了vue 登錄滑動(dòng)驗(yàn)證實(shí)現(xiàn)代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

在沒給大家講解實(shí)現(xiàn)代碼之前,先給大家分享效果圖:

之前別人都是用jq寫的,自己整理了一下開始使用

<el-form-item label="驗(yàn)證">
<div class="form-inline-input">
<div class="code-box" id="code-box">
<input type="text" name="code" class="code-input" />
<p></p>
<span>>>></span>
</div>
</div>
</el-form-item>

vue代碼

//獲取元素距離頁(yè)面邊緣的距離
getOffset(box,direction){
var setDirection = (direction == 'top') ? 'offsetTop' : 'offsetLeft' ;
var offset = box[setDirection];
var parentBox = box.offsetParent;
while(parentBox){
offset+=parentBox[setDirection];
parentBox = parentBox.offsetParent;
}
parentBox = null;
return parseInt(offset);
},
 moveCode(code,_this){
var fn = {codeVluae : code};
var box = document.querySelector("#code-box"),
progress = box.querySelector("p"),
codeInput = box.querySelector('.code-input'),
evenBox = box.querySelector("span");
//默認(rèn)事件
var boxEven = ['mousedown','mousemove','mouseup'];
//改變手機(jī)端與pc事件類型
if(typeof document.ontouchstart == 'object'){
boxEven = ['touchstart','touchmove','touchend'];
}
var goX,offsetLeft,deviation,evenWidth,endX;
function moveFn(e){
e.preventDefault();
e = (boxEven['0'] == 'touchstart') ? e.touches[0] : e || window.event;
endX = e.clientX - goX;
endX = (endX > 0) ? (endX > evenWidth) ? evenWidth : endX : 0;
if(endX > evenWidth * 0.7){
progress.innerText = '松開驗(yàn)證';
progress.style.backgroundColor = "#66CC66";
}else{
progress.innerText = '';
progress.style.backgroundColor = "#FFFF99";
}
progress.style.width = endX+deviation+'px';
evenBox.style.left = endX+'px';
}
function removeFn() {
document.removeEventListener(boxEven['2'],removeFn,false);
document.removeEventListener(boxEven['1'],moveFn,false);
if(endX > evenWidth * 0.7){
progress.innerText = '驗(yàn)證成功';
progress.style.width = evenWidth+deviation+'px';
evenBox.style.left = evenWidth+'px'
codeInput.value = fn.codeVluae;
evenBox.onmousedown = null;
_this.ruleForm.verification = true;
}else{
progress.style.width = '0px';
evenBox.style.left = '0px';
}
};
function getOffset(box,direction){
var setDirection = (direction == 'top') ? 'offsetTop' : 'offsetLeft' ;
var offset = box[setDirection];
var parentBox = box.offsetParent;
while(parentBox){
offset+=parentBox[setDirection];
parentBox = parentBox.offsetParent;
}
parentBox = null;
return parseInt(offset);
};
evenBox.addEventListener(boxEven['0'], function(e) {
e = (boxEven['0'] == 'touchstart') ? e.touches[0] : e || window.event;
goX = e.clientX,
offsetLeft = getOffset(box,'left'),
deviation = this.clientWidth,
evenWidth = box.clientWidth - deviation,
endX;
document.addEventListener(boxEven['1'],moveFn,false);
document.addEventListener(boxEven['2'],removeFn,false);
},false);
fn.setCode = function(code){
if(code)
fn.codeVluae = code;
}
fn.getCode = function(){
return fn.codeVluae;
}
fn.resetCode = function(){
evenBox.removeAttribute('style');
progress.removeAttribute('style');
codeInput.value = '';
};
return fn;
 }

調(diào)用

mounted(){
var _this = this;
// window.addEventListener('load',function(){
//code是后臺(tái)傳入的驗(yàn)證字符串
var code = "jsaidaisd656",
codeFn = new _this.moveCode(code,_this);
// });
}

驗(yàn)證樣式

.form-inline-input{
 border:1px solid #dadada;
border-radius:5px;
}
.form-inline-input input,
.code-box{
 padding: 0 3px;
width: 298px;
height: 40px;
color: #fff;
text-shadow: 1px 1px 1px black;
background: #efefef;
border: 0;
border-radius: 5px;
 outline: none;
}
.code-box{
 position: relative;
}
.code-box p,
.code-box span{
 display:block;
 position: absolute;
 left: 0;
 height: 40px;
 text-align: center;
 line-height: 40px;
 border-radius: 5px;
padding:0;
margin:0;
}
.code-box span{
 width: 40px;
 background-color:#fff;
 font-size: 16px;
 cursor: pointer;
margin-right:1px;
}
.code-box p{
 width: 0;
 background-color: #FFFF99;
 overflow: hidden;
 text-indent: -20px;
 transition: background 1s ease-in;
}
.code-box .code-input{
 display: none;
}
.code-box .code-input{
 display: none;
}
.form-inline-input{
 border:1px solid #dadada;
border-radius:5px;
}
.form-inline-input input,
.code-box{
 padding: 0 3px;
width: 298px;
height: 40px;
color: #fff;
text-shadow: 1px 1px 1px black;
background: #efefef;
border: 0;
border-radius: 5px;
 outline: none;
}
.code-box{
 position: relative;
}
.code-box p,
.code-box span{
 display:block;
 position: absolute;
 left: 0;
 height: 40px;
 text-align: center;
 line-height: 40px;
 border-radius: 5px;
padding:0;
margin:0;
}
.code-box span{
 width: 40px;
 background-color:#fff;
 font-size: 16px;
 cursor: pointer;
margin-right:1px;
}
.code-box p{
 width: 0;
 background-color: #FFFF99;
 overflow: hidden;
 text-indent: -20px;
 transition: background 1s ease-in;
}
.code-box .code-input{
 display: none;
}
.code-box .code-input{
 display: none;
}

總結(jié)

以上所述是小編給大家介紹的vue 登錄滑動(dòng)驗(yàn)證實(shí)現(xiàn)代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 使用vue實(shí)現(xiàn)簡(jiǎn)單鍵盤的示例(支持移動(dòng)端和pc端)

    使用vue實(shí)現(xiàn)簡(jiǎn)單鍵盤的示例(支持移動(dòng)端和pc端)

    這篇文章主要介紹了使用vue實(shí)現(xiàn)簡(jiǎn)單鍵盤的示例(支持移動(dòng)端和pc端),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-12-12
  • vue中watch如何同時(shí)監(jiān)聽多個(gè)屬性

    vue中watch如何同時(shí)監(jiān)聽多個(gè)屬性

    這篇文章主要介紹了vue中watch如何同時(shí)監(jiān)聽多個(gè)屬性,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • 使用elementUI實(shí)現(xiàn)將圖片上傳到本地的示例

    使用elementUI實(shí)現(xiàn)將圖片上傳到本地的示例

    今天小編就為大家分享一篇使用elementUI實(shí)現(xiàn)將圖片上傳到本地的示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-09-09
  • Vue中保存用戶登錄狀態(tài)實(shí)例代碼

    Vue中保存用戶登錄狀態(tài)實(shí)例代碼

    本篇文章主要介紹了Vue中保存用戶登錄狀態(tài)實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。、
    2017-06-06
  • vue使用echarts圖表的詳細(xì)方法

    vue使用echarts圖表的詳細(xì)方法

    這篇文章主要為大家詳細(xì)介紹了vue使用echarts圖表的詳細(xì)方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-10-10
  • Element Dropdown下拉菜單的使用方法

    Element Dropdown下拉菜單的使用方法

    這篇文章主要介紹了Element Dropdown下拉菜單的使用方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • Vue中@click.native的使用方法及場(chǎng)景

    Vue中@click.native的使用方法及場(chǎng)景

    在組件中時(shí)??吹紷click.native,在項(xiàng)目中遇到后,簡(jiǎn)單介紹下,這篇文章主要給大家介紹了關(guān)于Vue中@click.native的使用方法及場(chǎng)景的相關(guān)資料,需要的朋友可以參考下
    2023-11-11
  • vue3使用百度地圖超詳細(xì)圖文教程

    vue3使用百度地圖超詳細(xì)圖文教程

    這篇文章主要給大家介紹了關(guān)于vue3使用百度地圖的相關(guān)資料,最近一個(gè)項(xiàng)目要用到地圖,因?yàn)槲⑿判〕绦蛴玫囊彩前俣鹊貓D,所以想著網(wǎng)頁(yè)端也用百度地圖,需要的朋友可以參考下
    2023-07-07
  • vue中v-for數(shù)據(jù)狀態(tài)值變了,但是視圖沒改變的解決方案

    vue中v-for數(shù)據(jù)狀態(tài)值變了,但是視圖沒改變的解決方案

    這篇文章主要介紹了vue中v-for數(shù)據(jù)狀態(tài)值變了,但是視圖沒改變的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • 如何解決element-ui中select下拉框popper超出彈框問(wèn)題

    如何解決element-ui中select下拉框popper超出彈框問(wèn)題

    這篇文章主要介紹了如何解決element-ui中select下拉框popper超出彈框問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-04-04

最新評(píng)論

犍为县| 阿克陶县| 和政县| 枣强县| 朔州市| 苏尼特右旗| 贵德县| 万山特区| 盘山县| 曲水县| 察隅县| 兴海县| 黄石市| 鸡西市| 凯里市| 泸州市| 海阳市| 芦溪县| 赤城县| 黄梅县| 沙田区| 怀宁县| 柏乡县| 开封市| 建水县| 枞阳县| 汝州市| 日土县| 洪泽县| 安远县| 永福县| 临沧市| 和龙市| 昭通市| 涞源县| 阿拉善左旗| 彭山县| 通江县| 广元市| 青神县| 耒阳市|