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

vue實(shí)現(xiàn)原生下拉刷新

 更新時(shí)間:2022年03月08日 10:02:30   作者:至_臻  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)原生下拉刷新,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)原生下拉刷新的具體代碼,供大家參考,具體內(nèi)容如下

這是動(dòng)畫樣式 

 文字樣式

html代碼

<template>
? <div class="car-box">
? ? <div class="car">下拉刷新</div>
? ? <div class="box" @touchstart="fnstart" ref="Element">
? ? ? <div class="con-txt">上拉刷新</div>
? ? </div>
? </div>
</template>

js代碼

<script>
export default {
? methods: {
? ? fnstart(ev) {
? ? ? this.$refs["Element"].style.top = 0;
? ? ? this.scroolTop =
? ? ? ? ev.changedTouches[0].pageY - this.$refs["Element"].offsetTop;
?
? ? ? document.ontouchmove = this.fnmove;
? ? ? document.ontouchend = this.fnEnd;
? ? ? ev.preventDefault && ev.preventDefault();
? ? },
? ? fnmove(ev) {
? ? ? ev.target.parentNode.children[0].innerHTML = "下拉刷新";
? ? ? this.T = ev.changedTouches[0].pageY - this.scroolTop;
? ? ? if (this.scale > 0.12) {
? ? ? ? this.scale = 1 - this.T / 200;
? ? ? } else {
? ? ? ? this.scale = 0.12;
? ? ? }
? ? ? this.$refs["Element"].style.top = this.T * this.scale + "px";
? ? },
? ? fnEnd(ev) {
? ? ? ev.target.parentNode.children[0].innerHTML = "正在刷新...";
? ? ? document.ontouchmove = null;
? ? ? document.ontouchend = null;
? ? ? setTimeout(() => {
? ? ? ? this.$refs["Element"].style.top = 0;
? ? ? ? this.$refs["Element"].style.transition = ".3s ease all";
? ? ? ? this.$refs["Element"].addEventListener("transitionend", () => {
? ? ? ? ? this.$refs["Element"].style.transition = null;
? ? ? ? });
? ? ? }, 3000);
? ? },
? },
};
</script>

css代碼  我這邊用的是scss 

<style lang="scss" scoped>
.box {
? text-align: center;
? height: 600px;
? width: 100vw;
? background-color: orange;
? position: absolute;
? left: 0;
? top: 0;
}
.car {
? text-align: center;
? margin: auto;
? width: 199px;
? height: 60px;
? line-height: 60px;
? background-position: 0 0;
? background-size: 100% auto;
? animation: animation_car 1.5s steps(1) infinite;
}
</style>

如果下拉刷新用動(dòng)畫就用這個(gè)css樣式 

圖片的話我用的是28幀的 根據(jù)100除以28  也就是3.5 ,所以每3.5%換一個(gè)圖,就能形成一個(gè)逐幀動(dòng)畫,每一個(gè)頁面的寬高都不一樣所以要計(jì)算 ,我的頁面的大小是1080的這個(gè)也時(shí)我設(shè)置好的寬高。

這是代碼

<style lang="scss" scoped>
.box {
? text-align: center;
? height: 600px;
? width: 100vw;
? background-color: orange;
? position: absolute;
? left: 0;
? top: 0;
}
.car {
? text-align: center;
? margin: auto;
? width: 199px;
? height: 134px;
? // ? margin-bottom: 200px;
? background: url("../assets/img/car.png") no-repeat;
? background-position: 0 0;
? background-size: 100% auto;
? animation: animation_car 1.5s steps(1) infinite;
}
@keyframes animation_car {
? 0% {
? ? background-position: 0px;
? }
? 3.5% {
? ? background-position: 0px -134px;
? }
? 7% {
? ? background-position: 0px -268px;
? }
? 10.5% {
? ? background-position: 0px -402px;
? }
? 14% {
? ? background-position: 0px -536px;
? }
? 17.5% {
? ? background-position: 0px -670px;
? }
? 21% {
? ? background-position: 0px -804px;
? }
? 24.5% {
? ? background-position: 0px -938px;
? }
? 28% {
? ? background-position: 0px -1072px;
? }
? 31.5% {
? ? background-position: 0px -1206px;
? }
? 35% {
? ? background-position: 0px -1340px;
? }
? 38.5% {
? ? background-position: 0px -1474px;
? }
? 42% {
? ? background-position: 0px -1608px;
? }
? 45.5% {
? ? background-position: 0px -1742px;
? }
? 49% {
? ? background-position: 0px -1876px;
? }
? 52.5% {
? ? background-position: 0px -2010px;
? }
? 56% {
? ? background-position: 0px -2144px;
? }
? 59.5% {
? ? background-position: 0px -2278px;
? }
? 63% {
? ? background-position: 0px -2412px;
? }
? 66.5% {
? ? background-position: 0px -2546px;
? }
? 70% {
? ? background-position: 0px -2680px;
? }
? 73.5% {
? ? background-position: 0px -2814px;
? }
? 77% {
? ? background-position: 0px -2948px;
? }
? 80.5% {
? ? background-position: 0px -3082px;
? }
? 84% {
? ? background-position: 0px -3216px;
? }
? 87.5% {
? ? background-position: 0px -3350px;
? }
? 91% {
? ? background-position: 0px -3350px;
? }
? 94.5% {
? ? background-position: 0px -3484px;
? }
? 98% {
? ? background-position: 0px -3618px;
? }
}
?
</style>

圖片

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

相關(guān)文章

  • vue從零實(shí)現(xiàn)一個(gè)消息通知組件的方法詳解

    vue從零實(shí)現(xiàn)一個(gè)消息通知組件的方法詳解

    這篇文章主要介紹了vue從零實(shí)現(xiàn)一個(gè)消息通知組件的方法,結(jié)合實(shí)例形式分析了vue實(shí)現(xiàn)消息通知組件的具體原理、實(shí)現(xiàn)步驟、與相關(guān)操作技巧,需要的朋友可以參考下
    2020-03-03
  • vuex直接修改state、commit和dispatch修改state的用法及區(qū)別說明

    vuex直接修改state、commit和dispatch修改state的用法及區(qū)別說明

    這篇文章主要介紹了vuex直接修改state、commit和dispatch修改state的用法及區(qū)別說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • vue 如何將二維數(shù)組轉(zhuǎn)化為一維數(shù)組

    vue 如何將二維數(shù)組轉(zhuǎn)化為一維數(shù)組

    這篇文章主要介紹了vue 如何將二維數(shù)組轉(zhuǎn)化為一維數(shù)組,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue的keep-alive中使用EventBus的方法

    vue的keep-alive中使用EventBus的方法

    keep-alive是Vue提供的一個(gè)抽象組件,用來對(duì)組件進(jìn)行緩存,從而節(jié)省性能,由于是一個(gè)抽象組件,所以在頁面渲染完畢后不會(huì)被渲染成一個(gè)DOM元素。這篇文章主要介紹了vue的keep-alive中使用EventBus的方法,需要的朋友可以參考下
    2019-04-04
  • 詳解jquery和vue對(duì)比

    詳解jquery和vue對(duì)比

    這篇文章主要介紹了jquery和vue對(duì)比,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Vue項(xiàng)目中定義全局變量的幾種常用方法總結(jié)

    Vue項(xiàng)目中定義全局變量的幾種常用方法總結(jié)

    在項(xiàng)目中經(jīng)常有些函數(shù)和變量是需要復(fù)用,比如說網(wǎng)站服務(wù)器地址,從后臺(tái)拿到的用戶的登錄token,用戶的地址信息等,這時(shí)候就需要設(shè)置一波全局變量,這篇文章主要給大家介紹了關(guān)于Vue項(xiàng)目中定義全局變量的幾種常用方法的相關(guān)資料,需要的朋友可以參考下
    2023-12-12
  • 關(guān)于vue3中setup函數(shù)的使用

    關(guān)于vue3中setup函數(shù)的使用

    這篇文章主要介紹了關(guān)于vue3中setup函數(shù)的使用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue3接口數(shù)據(jù)賦值對(duì)象,渲染報(bào)錯(cuò)問題及解決

    vue3接口數(shù)據(jù)賦值對(duì)象,渲染報(bào)錯(cuò)問題及解決

    這篇文章主要介紹了vue3接口數(shù)據(jù)賦值對(duì)象,渲染報(bào)錯(cuò)問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • Vue使用konva實(shí)現(xiàn)一個(gè)簡便的流程圖

    Vue使用konva實(shí)現(xiàn)一個(gè)簡便的流程圖

    日常開發(fā)中我們可能碰到流程圖的需求,實(shí)現(xiàn)流程圖的庫有很多,如果我們想要實(shí)現(xiàn)一個(gè)簡便的流程圖可以使用konva庫來實(shí)現(xiàn),下面我們就來看一下具體的實(shí)現(xiàn)過程,需要的朋友可以參考下
    2023-08-08
  • 解決vue安裝less報(bào)錯(cuò)Failed to compile with 1 errors的問題

    解決vue安裝less報(bào)錯(cuò)Failed to compile with 1 errors的問題

    這篇文章主要介紹了解決vue安裝less報(bào)錯(cuò)Failed to compile with 1 errors的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10

最新評(píng)論

长岛县| 哈巴河县| 长乐市| 板桥市| 鹰潭市| 蓝田县| 大连市| 余江县| 临清市| 光泽县| 晋江市| 民权县| 金乡县| 棋牌| 古交市| 郴州市| 泰安市| 邹城市| 武邑县| 山丹县| 宿松县| 通州区| 运城市| 南靖县| 鸡东县| 大埔县| 额敏县| 盘山县| 上饶县| 永寿县| 盐池县| 汝南县| 台东县| 揭东县| 当涂县| 五原县| 绿春县| 汽车| 贵阳市| 富阳市| 海口市|