欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue2 mint-ui loadmore實(shí)現(xiàn)下拉刷新,上拉更多功能

 更新時間:2018年03月21日 09:09:41   作者:岳小哥  
這篇文章主要介紹了vue2 mint-ui loadmore實(shí)現(xiàn)下拉刷新,上拉更多功能,需要的朋友可以參考下

mintui是餓了么團(tuán)隊(duì)針對vue開發(fā)的移動端組件庫,方便實(shí)現(xiàn)移動端的一些功能,這里主要給大家介紹vue2 mint-ui loadmore實(shí)現(xiàn)下拉刷新,上拉更多功能,具體代碼如下所示:

<template>
 <div class="page-loadmore">
  <h1 class="page-title">Pull up</h1>
  <p class="page-loadmore-desc">在列表底部, 按住 - 上拉 - 釋放可以獲取更多數(shù)據(jù)</p>
  <p class="page-loadmore-desc">translate : {{ translate }}</p>
  <div class="loading-background" :style="{ transform: 'scale3d(' + moveTranslate + ',' + moveTranslate + ',1)' }">
   translateScale : {{ moveTranslate }}
  </div>
  <div class="page-loadmore-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }">
   <mt-loadmore :top-method="loadTop" @translate-change="translateChange" @top-status-change="handleTopChange"    :bottom-method="loadBottom" @bottom-status-change="handleBottomChange" :bottom-all-loaded="allLoaded" ref="loadmore">
    <ul class="page-loadmore-list">
     <li v-for="item in list" class="page-loadmore-listitem">{{ item }}</li>
    </ul>
    <div slot="top" class="mint-loadmore-top">
     <span v-show="topStatus !== 'loading'" :class="{ 'is-rotate': topStatus === 'drop' }">↓</span>
     <span v-show="topStatus === 'loading'">
      <mt-spinner type="snake"></mt-spinner>
     </span>
    </div>
    <div slot="bottom" class="mint-loadmore-bottom">
     <span v-show="bottomStatus !== 'loading'" :class="{ 'is-rotate': bottomStatus === 'drop' }">↑</span>
     <span v-show="bottomStatus === 'loading'">
      <mt-spinner type="snake"></mt-spinner>
     </span>
    </div>
   </mt-loadmore>
  </div>
 </div>
</template>
<style>
 .loading-background, .mint-loadmore-top span {
  -webkit-transition: .2s linear;
  transition: .2s linear
 }
 .mint-loadmore-top span {
  display: inline-block;
  vertical-align: middle
 }
 .mint-loadmore-top span.is-rotate {
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg)
 }
 .page-loadmore .mint-spinner {
  display: inline-block;
  vertical-align: middle
 }
 .page-loadmore-desc {
  text-align: center;
  color: #666;
  padding-bottom: 5px
 }
 .page-loadmore-desc:last-of-type,
 .page-loadmore-listitem {
  border-bottom: 1px solid #eee
 }
 .page-loadmore-listitem {
  height: 50px;
  line-height: 50px;
  text-align: center
 }
 .page-loadmore-listitem:first-child {
  border-top: 1px solid #eee
 }
 .page-loadmore-wrapper {
  overflow: scroll
 }
 .mint-loadmore-bottom span {
  display: inline-block;
  -webkit-transition: .2s linear;
  transition: .2s linear;
  vertical-align: middle
 }
 .mint-loadmore-bottom span.is-rotate {
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg)
 }
</style>
<script type="text/babel">
 export default {
  data() {
   return {
    list: [],
    allLoaded: false,
    bottomStatus: '',
    wrapperHeight: 0,
    topStatus: '',
    //wrapperHeight: 0,
    translate: 0,
    moveTranslate: 0
   };
  },
  methods: {
   handleBottomChange(status) {
    this.bottomStatus = status;
   },
   loadBottom() {
    setTimeout(() => {
     let lastValue = this.list[this.list.length - 1];
     if (lastValue < 40) {
      for (let i = 1; i <= 10; i++) {
       this.list.push(lastValue + i);
      }
     } else {
      this.allLoaded = true;
     }
     this.$refs.loadmore.onBottomLoaded();
    }, 1500);
   },
   handleTopChange(status) {
    this.moveTranslate = 1;
    this.topStatus = status;
   },
   translateChange(translate) {
    const translateNum = +translate;
    this.translate = translateNum.toFixed(2);
    this.moveTranslate = (1 + translateNum / 70).toFixed(2);
   },
   loadTop() {
    setTimeout(() => {
     let firstValue = this.list[0];
     for (let i = 1; i <= 10; i++) {
      this.list.unshift(firstValue - i);
     }
     this.$refs.loadmore.onTopLoaded();
    }, 1500);
   },
  },
  created() {
   for (let i = 1; i <= 20; i++) {
    this.list.push(i);
   }
  },
  mounted() {
   this.wrapperHeight = document.documentElement.clientHeight - this.$refs.wrapper.getBoundingClientRect().top;
  }
 };
</script>

總結(jié)

以上所述是小編給大家介紹的vue2 mint-ui loadmore實(shí)現(xiàn)下拉刷新,上拉更多功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Vue路由跳轉(zhuǎn)問題記錄詳解

    Vue路由跳轉(zhuǎn)問題記錄詳解

    本篇文章主要介紹了Vue路由跳轉(zhuǎn)問題記錄詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • vue2實(shí)現(xiàn)數(shù)據(jù)請求顯示loading圖

    vue2實(shí)現(xiàn)數(shù)據(jù)請求顯示loading圖

    這篇文章主要為大家詳細(xì)介紹了vue2實(shí)現(xiàn)數(shù)據(jù)請求顯示loading圖,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • 一文詳解Vue3中的setup函數(shù)的用法和原理

    一文詳解Vue3中的setup函數(shù)的用法和原理

    在 Vue3 中,setup 函數(shù)是一個新引入的概念,它代替了之前版本中的 data、computed、methods 等選項(xiàng),用于設(shè)置組件的初始狀態(tài)和邏輯,本文將主要介紹Setup的基本用法和少量原理
    2024-02-02
  • LRU算法在Vue內(nèi)置組件keep-alive中的使用

    LRU算法在Vue內(nèi)置組件keep-alive中的使用

    LRU算法全稱為least recently use 最近最少使用,核心思路是最近被訪問的以后被訪問的概率會變高,那么可以把之前沒被訪問的進(jìn)行刪除,維持一個穩(wěn)定的最大容量值,從而不會導(dǎo)致內(nèi)存溢出。
    2021-05-05
  • Vue項(xiàng)目打包部署到apache服務(wù)器的方法步驟

    Vue項(xiàng)目打包部署到apache服務(wù)器的方法步驟

    這篇文章主要介紹了Vue項(xiàng)目打包部署到apache服務(wù)器,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • vue3生成隨機(jī)密碼的示例代碼

    vue3生成隨機(jī)密碼的示例代碼

    本文主要介紹了vue3生成隨機(jī)密碼的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • vue2文件流下載成功后文件格式錯誤、打不開及內(nèi)容缺失的解決方法

    vue2文件流下載成功后文件格式錯誤、打不開及內(nèi)容缺失的解決方法

    使用Vue時我們前端如何處理后端返回的文件流,下面這篇文章主要給大家介紹了關(guān)于vue2文件流下載成功后文件格式錯誤、打不開及內(nèi)容缺失的解決方法,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-04-04
  • vue實(shí)現(xiàn)導(dǎo)航標(biāo)題欄隨頁面滾動漸隱漸顯效果

    vue實(shí)現(xiàn)導(dǎo)航標(biāo)題欄隨頁面滾動漸隱漸顯效果

    這篇文章主要介紹了vue實(shí)現(xiàn)導(dǎo)航標(biāo)題欄隨頁面滾動漸隱漸顯效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-03-03
  • nuxtjs中如何對axios二次封裝

    nuxtjs中如何對axios二次封裝

    這篇文章主要介紹了nuxtjs中如何對axios二次封裝問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • Vue自定義指令實(shí)現(xiàn)checkbox全選功能的方法

    Vue自定義指令實(shí)現(xiàn)checkbox全選功能的方法

    下面小編就為大家分享一篇Vue自定義指令實(shí)現(xiàn)checkbox全選功能的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02

最新評論