Pure JS Implementation load more (Vue framework)

Source: Internet
Author: User

Tag:data   script    Update    str   promise     distance    read   resources   method   

<template> <div class = ' car_list ' reft= ' scrollobx ' @scroll = ' scrollready ($event) ' > </div></temp Late><script> Export Default {data () {return {lengththreshold:50,///when sliding to            From low end 50px, update data timethreshold:300, Promise:null}}, methods: { Scroll load list Scrollready () {if (This.shouldscroll ()) {if (This.promis                    e) {return;                    }//Load This.fn ();                    Prevent multiple swipe, frequently request background resources let Self = this;                    This.promise = SetTimeout (() = {self.promise = null;                }, This.timethreshold);            }},//Call the parent component to request the Resource service FN () {this. $emit (' Scrollchange '); }, Shouldscroll () {if (docUment.scrolltop = = 0) {//sliding distance of 0, not beginning to slide return false; }
List height-list visual height-sliding height < 50px, load more return this. $refs. scrollbox.scrollheight-this. $refs. Scrollbox. Clientheight-this. $refs. scrollbox.scrolltop < This.lengththreshold; },}}</script>

Request Service method for parent component:

Querycarapplysharelist () {this        . Load = true;        CarResources.methods.queryCarApplyShareList (This.http, This.pageno, this.pagesize). Then (res) + = {          if (res && Res.status = = =) {               if (This.pageno = = = 1) {//Load first page data this                   . Carlist = Res.data | | [];               } else {//load more this                  . Carlist.concat (res.data);               }               This. Islastpage = Res.data.length = = = 0          } this          . Load = false;       }, () = = {this          . Load = false;          Console.log (' interface error ');}       );

  

Pure JS Implementation load more (Vue framework)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.