How to Use the pull-down refresh component in mescroll. js,

Source: Internet
Author: User

How to Use the pull-down refresh component in mescroll. js,

This article shares the code of the pull-up and pull-down refresh component mescroll. js for your reference. The details are as follows:

The link is http://www.mescroll.com/api.html?npm, which can be used by both the mobile phone end and the browser. Only recommended;
Pay attention to these problems during use: http://www.mescroll.com/qa.html;

Note:

1. Check the solution provided by the official website in time for any problems during the introduction (which must be viewed basically );

2. react must be initialized in the didMount method after dom rendering because the dom object needs to be obtained;

3. In the react project, the callback data must be spliced. This is worth noting (datas: ctx. state. datas. concat (json.info ));

4. It is very difficult to set the html and body height of a single page to 100%.

The simple code is attached below

import React, { Component, PropTypes } from 'react'; import MeScroll from "mescroll.js"  class StretchingUp extends Component {   constructor(props, context) {     super(props, context);     this.state={       datas:[],       total:0,     }     this.test = this.test.bind(this);   }   componentDidMount(){     document.ondragstart=function() {return false;}     let ctx = this;     var mescroll = new MeScroll ( "mescroll" , {down : { use:false}, up : {       use:true,       auto:true,       offSet:100,       page:{         num:0,         size:20,         time:null       },       onScroll:function(mescroll, y, isUp){       },       callback:function (page, mescroll) {         ctx.test(page, mescroll);       },       error: function (e) {       }     }} ) ;     mescroll.resetUpScroll()   }   test(page, mescroll){     console.log(page)     let url = "http://localhost:5577/curpage/"+page.num+"/pagesize/"+page.size;     let ctx = this;     fetch(url,{       method:'GET',       headers: {         'Accept': 'application/json',         'Content-Type': 'application/json',       },     }).then((resp)=>{       if(resp){         return resp.json();       }else{         return false;       }     })     .then((json)=>{         ctx.setState({         datas:ctx.state.datas.concat(json.info),         total:json.total       },()=>{     })      mescroll.endSuccess();     return true;   });   }   render() {     return (       <div id="mescroll" className="mescroll" style={{height: "500px",overflow: "auto"}}>       {this.state.datas.map((item,index)=>(         <div key={index}>           {item.id}         </div>       ))}       </div>   );   }}  export default StretchingUp; 

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

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.