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

vue滑動(dòng)解鎖組件使用方法詳解

 更新時(shí)間:2022年03月03日 11:49:20   作者:qq_34096214  
這篇文章主要為大家詳細(xì)介紹了vue滑動(dòng)解鎖組件的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue滑動(dòng)解鎖組件的使用,供大家參考,具體內(nèi)容如下

這是一個(gè)pc端的滑動(dòng)解鎖組件

效果圖:

話不多說(shuō),直接上代碼

html部分

<template>
? ? <div class="dragVerify">
? ? ? ? <div class="spout" ref="spout">
? ? ? ? ? ? <div
? ? ? ? ? ? ? ? class="slidingBlock"
? ? ? ? ? ? ? ? ref="slidingBlock"
? ? ? ? ? ? ? ? :style="{ left: `${place}%` }"
? ? ? ? ? ? ? ? @mousedown="mousedown($event)"
? ? ? ? ? ? ? ? :class="place < distance ? 'unfinished' : 'complete'"
? ? ? ? ? ? ></div>
? ? ? ? ? ? <div class="succeedBox" :class="place >= distance ? 'succeedText' : ''" :style="{ width: `${place}%` }"></div>
? ? ? ? </div>
? ? </div>
</template>

js部分

export default {
? ? name: 'dragVerify',
? ? data() {
? ? ? ? return {
? ? ? ? ? ? place: 0,
? ? ? ? ? ? sliding: {
? ? ? ? ? ? ? ? isDown: true,
? ? ? ? ? ? ? ? X: 0 // 初始X值
? ? ? ? ? ? },
? ? ? ? ? ? move: {
? ? ? ? ? ? ? ? X: 0 // 移動(dòng)X值
? ? ? ? ? ? },
? ? ? ? ? ? spoutW: 0,
? ? ? ? ? ? slidingBlockW: 0,
? ? ? ? ? ? distance: 1 // 要移動(dòng)的距離
? ? ? ? }
? ? },
? ? mounted() {},
? ? methods: {
? ? ? ? // 鼠標(biāo)事件
? ? ? ? mousedown(e) {
? ? ? ? ? ? if (this.place < this.distance) {
? ? ? ? ? ? ? ? this.sliding.isDown = true
? ? ? ? ? ? ? ? // 計(jì)算百分比
? ? ? ? ? ? ? ? this.spoutW = this.$refs.spout.offsetWidth
? ? ? ? ? ? ? ? this.slidingBlockW = this.$refs.slidingBlock.offsetWidth
? ? ? ? ? ? ? ? this.distance = 100 - (this.slidingBlockW / this.spoutW) * 100
? ? ? ? ? ? }
? ? ? ? ? ? this.sliding.X = e.x
? ? ? ? ? ? // 添加鼠標(biāo)的移動(dòng)事件
? ? ? ? ? ? document.addEventListener('mousemove', e => {
? ? ? ? ? ? ? ? if (this.sliding.isDown) {
? ? ? ? ? ? ? ? ? ? this.move.X = e.x
? ? ? ? ? ? ? ? ? ? if (this.place >= this.distance) {
? ? ? ? ? ? ? ? ? ? ? ? this.place = this.distance
? ? ? ? ? ? ? ? ? ? } else if (this.place >= 0 && this.place < this.distance) {
? ? ? ? ? ? ? ? ? ? ? ? this.place = ((this.move.X - this.sliding.X) / this.spoutW) * 100
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? if (this.place <= 0) {
? ? ? ? ? ? ? ? ? ? ? ? this.place = 0
? ? ? ? ? ? ? ? ? ? ? ? document.removeEventListener('mousemove', null, false)
? ? ? ? ? ? ? ? ? ? ? ? return
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? e.preventDefault()
? ? ? ? ? ? })
? ? ? ? ? ? // 松開(kāi)鼠標(biāo)
? ? ? ? ? ? document.onmouseup = e => {
? ? ? ? ? ? ? ? if (this.place == this.distance) {
? ? ? ? ? ? ? ? ? ? this.$emit('setVerify', true)
? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? this.sliding.isDown = false
? ? ? ? ? ? ? ? ? ? this.place = 0
? ? ? ? ? ? ? ? ? ? this.$emit('setVerify', false)
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}

css部分

.dragVerify {
? ? border: 1px solid #e1e1e1;
? ? height: 40px;
? ? background: #eeeeee;
}
.spout {
? ? line-height: 40px;
? ? height: 40px;
? ? /* text-align: center; */
? ? position: relative;
? ? width: 293px;
}
.spout::before {
? ? content: '請(qǐng)按住滑塊,拖動(dòng)到最右邊';
? ? width: 233px;
? ? top: 0;
? ? right: 0;
? ? bottom: 0;
? ? color: #919593;
? ? font-size: 16px;
? ? text-align: center;
? ? position: absolute;
}
.succeedText::before {
? ? content: '驗(yàn)證通過(guò)';
? ? width: 233px;
? ? top: 0;
? ? right: 0;
? ? bottom: 0;
? ? color: #ffffff;
? ? font-size: 16px;
? ? text-align: center;
? ? position: absolute;
}
.succeedBox {
? ? color: #ffffff;
? ? font-size: 16px;
? ? text-align: center;
? ? line-height: 38px;
? ? height: 38px;
? ? position: absolute;
? ? top: 0;
? ? left: 0;
? ? right: 0;
? ? bottom: 0;
? ? background: #23b14d;
? ? z-index: 8;
}
.slidingBlock {
? ? width: 60px;
? ? /* height: 38px; */
? ? height: calc(100% - 0.1rem);
? ? border: 1px solid #e1e1e1;
? ? border-top: none;
? ? /* border-bottom: none; */
? ? border-left: none;
? ? background: #ffffff;
? ? position: absolute;
? ? top: 0;
? ? bottom: 0;
? ? left: 0;
? ? /* margin-left: -1px; */
? ? cursor: move;
? ? z-index: 9;
}
.slidingBlock::after {
? ? content: '';
? ? position: absolute;
? ? background-size: 100% 100%;
? ? background-repeat: no-repeat;
? ? width: 20px;
? ? height: 20px;
? ? left: 50%;
? ? top: 50%;
? ? margin-left: -10px;
? ? margin-top: -10px;
}
.unfinished::after {
? ? background-image: url(你的圖片);
}
.complete::after {
? ? background-image: url(你的圖片);
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 前端VUE雙語(yǔ)實(shí)現(xiàn)方案詳細(xì)教程

    前端VUE雙語(yǔ)實(shí)現(xiàn)方案詳細(xì)教程

    在項(xiàng)目需求中我們會(huì)遇到國(guó)際化的中英文切換,這篇文章主要給大家介紹了關(guān)于前端VUE雙語(yǔ)實(shí)現(xiàn)方案的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-08-08
  • Vue全局監(jiān)測(cè)錯(cuò)誤并生成錯(cuò)誤日志實(shí)現(xiàn)方法介紹

    Vue全局監(jiān)測(cè)錯(cuò)誤并生成錯(cuò)誤日志實(shí)現(xiàn)方法介紹

    在做完一個(gè)項(xiàng)目后,之后的維護(hù)尤為重要。這時(shí),如果項(xiàng)目配置了錯(cuò)誤日志記錄,這樣能大大減少維護(hù)難度。雖然不一定能捕獲到全部的錯(cuò)誤,但是一般的錯(cuò)誤還是可以監(jiān)測(cè)到的。這樣就不用測(cè)試人員去一遍一遍復(fù)現(xiàn)bug了
    2022-10-10
  • vue?filters和directives訪問(wèn)this的問(wèn)題詳解

    vue?filters和directives訪問(wèn)this的問(wèn)題詳解

    這篇文章主要介紹了vue?filters和directives訪問(wèn)this的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • vsCode安裝配置創(chuàng)建Vue3項(xiàng)目全過(guò)程

    vsCode安裝配置創(chuàng)建Vue3項(xiàng)目全過(guò)程

    本文介紹了如何在Windows系統(tǒng)上安裝和配置Vue.js開(kāi)發(fā)環(huán)境,包括安裝VS Code、Node.js、Vue CLI以及創(chuàng)建和啟動(dòng)一個(gè)Vue項(xiàng)目
    2025-01-01
  • 詳解Vue組件實(shí)現(xiàn)tips的總結(jié)

    詳解Vue組件實(shí)現(xiàn)tips的總結(jié)

    這篇文章主要介紹了詳解Vue組件實(shí)現(xiàn)tips的總結(jié),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-11-11
  • Vuex報(bào)錯(cuò)之[vuex] unknown mutation type: handlePower問(wèn)題及解決

    Vuex報(bào)錯(cuò)之[vuex] unknown mutation type: han

    這篇文章主要介紹了Vuex報(bào)錯(cuò)之[vuex] unknown mutation type: handlePower問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Delete `,` 如何解決(vue eslint與prettier沖突)

    Delete `,` 如何解決(vue eslint與prettier沖突)

    這篇文章主要介紹了Delete `,` 如何解決(vue eslint與prettier沖突)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • vue實(shí)現(xiàn)列表滑動(dòng)下拉加載數(shù)據(jù)的方法

    vue實(shí)現(xiàn)列表滑動(dòng)下拉加載數(shù)據(jù)的方法

    文章介紹了如何使用Vue實(shí)現(xiàn)列表滑動(dòng)下拉加載數(shù)據(jù)的功能,通過(guò)監(jiān)聽(tīng)滾動(dòng)事件,檢測(cè)用戶是否滾動(dòng)到底部,然后動(dòng)態(tài)加載更多數(shù)據(jù),附帶了實(shí)現(xiàn)思路和案例代碼,感興趣的朋友一起看看吧
    2024-11-11
  • Vue.js使用computed屬性實(shí)現(xiàn)數(shù)據(jù)自動(dòng)更新

    Vue.js使用computed屬性實(shí)現(xiàn)數(shù)據(jù)自動(dòng)更新

    在Vue組件中,computed屬性是在組件的選項(xiàng)對(duì)象中聲明的,你可以把它們想象成組件的一個(gè)小功能,告訴Vue當(dāng)某些數(shù)據(jù)變化時(shí),如何更新界面,本文給大家介紹了Vue.js使用computed屬性實(shí)現(xiàn)數(shù)據(jù)自動(dòng)更新,需要的朋友可以參考下
    2024-06-06
  • elementUI組件中el-date-picker限制時(shí)間范圍精確到小時(shí)的方法

    elementUI組件中el-date-picker限制時(shí)間范圍精確到小時(shí)的方法

    現(xiàn)在需要做一個(gè)時(shí)間選擇器,可以根據(jù)小時(shí)(同時(shí)選天和小時(shí))和天?和月,節(jié)假日等類(lèi)型控制日歷的選擇樣式,下面這篇文章主要給大家介紹了關(guān)于elementUI組件中el-date-picker限制時(shí)間范圍精確到小時(shí)的相關(guān)資料,需要的朋友可以參考下
    2023-04-04

最新評(píng)論

东明县| 潜山县| 内乡县| 黄石市| 卢湾区| 长泰县| 内丘县| 墨脱县| 无为县| 高密市| 鲁山县| 若尔盖县| 兖州市| 耿马| 禹城市| 昂仁县| 巴林左旗| 阿拉善盟| 库车县| 徐水县| 新巴尔虎左旗| 阳谷县| 松原市| 芦溪县| 枣阳市| 揭阳市| 岳池县| 桐庐县| 肥西县| 温州市| 聂拉木县| 仙桃市| 溆浦县| 远安县| 天津市| 墨玉县| 大埔区| 鹤庆县| 新津县| 连南| 西吉县|