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

基于JS實(shí)現(xiàn)父組件的請(qǐng)求服務(wù)過(guò)程解析

 更新時(shí)間:2019年10月14日 09:27:50   作者:彭勝光  
這篇文章主要介紹了基于JS實(shí)現(xiàn)父組件的請(qǐng)求服務(wù)過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了基于JS實(shí)現(xiàn)父組件的請(qǐng)求服務(wù)過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

<template>
 <div class = 'car_list' reft='scrollobx' @scroll='scrollready($event)'>
 </div>
</template>
<script>
 export default {
  data() {
   return {
    lengthThreshold: 50, //當(dāng)滑動(dòng)到距離低端50px時(shí),更新數(shù)據(jù)
    timeThreshold: 300,
    promise: null
   }
  },
  methods: {
   // 滾動(dòng)加載列表
   scrollready() {
    if(this.shouldScroll()) {
     if (this.promise) {
      return;
     }
     // 進(jìn)行加載
     this.fn();
     // 防止多次滑動(dòng),頻繁請(qǐng)求后臺(tái)資源
     let self = this;
     this.promise = setTimeout(() => {
      self.promise = null;
     }, this.timeThreshold);
    }
   },
   // 調(diào)用父組件請(qǐng)求資源服務(wù)
   fn() {
    this.$emit('scrollChange');
   },
   shouldScroll() {
    if(document.scrollTop === 0) {// 滑動(dòng)距離為0,還沒(méi)開(kāi)始滑動(dòng)
     return false;
    }<br data-filtered="filtered">    // 列表高度 - 列表可視高度 - 滑動(dòng)的高度 < 50px , 則加載更多
    return this.$refs.scrollbox.scrollHeight - this.$refs.scrollbox.clientHeight - this.$refs.scrollbox.scrollTop < this.lengthThreshold;
   },
  }
 }
</script> 

父組件的請(qǐng)求服務(wù)方法:

queryCarApplyShareList() {
  this.Load = true;
  CarResources.methods.queryCarApplyShareList(this.http, this.pageNo, this.pageSize).then((res) => {
   if (res && res.status === 200) {
    if (this.pageNo === 1) { // 加載第一頁(yè)數(shù)據(jù)
     this.CarList = res.data || [];
    } else { // 加載更多
     this.CarList = <strong>this.CarList.concat(res.data);</strong>
    }
    this.IsLastPage = res.data.length === 0
   }
   this.Load = false;
  }, () => {
   this.Load = false;
   console.log('接口報(bào)錯(cuò)');
  });
},

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

相關(guān)文章

最新評(píng)論

蓝田县| 巨鹿县| 当阳市| 绍兴市| 射阳县| 佳木斯市| 临猗县| 景泰县| 平乡县| 综艺| 阿克陶县| 页游| 江北区| 宁阳县| 林周县| 元谋县| 金堂县| 九江县| 洪洞县| 桐城市| 呈贡县| 开原市| 涿鹿县| 积石山| 栾城县| 吉林省| 旅游| 海阳市| 宁德市| 江都市| 丘北县| 衢州市| 临城县| 平顺县| 营山县| 景泰县| 五台县| 甘孜县| 南投市| 安平县| 锡林浩特市|