vue 登入滑動驗證
阿新 • • 發佈:2019-02-14
之前別人都是用jq寫的,自己整理了一下開始使用
<el-form-item label="驗證"> <div class="form-inline-input"> <div class="code-box" id="code-box"> <input type="text" name="code" class="code-input" /> <p></p> <spanvue程式碼
//獲取元素距離頁面邊緣的距離 getOffset(box,direction){ var setDirection = (direction == 'top') ? 'offsetTop' : 'offsetLeft' ; var offset = box[setDirection]; var parentBox =呼叫
mounted(){ var _this = this; // window.addEventListener('load',function(){ //code是後臺傳入的驗證字串 var code = "jsaidaisd656", codeFn = new _this.moveCode(code,_this); // }); }驗證樣式
.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;}
展示