How to implement pull-up loading in WeChat applet development

php中世界最好的语言
Release: 2018-06-05 11:12:22
Original
3060 people have browsed it

This time I will show you how to implement pull-up loading in WeChat applet development. What are the precautions for pull-up loading in WeChat applet development? The following is a practical case, let’s take a look.

My current company's project is an e-commerce applet, which can be refreshed by pulling down. The official website clearly states that it cannot be used with scroll-view at the same time. I used onReachBottom and scroll-view's bindscrolltolower out of the blue. After my practice, I recommend everyone to use onReachBottom. If there are pull-down refreshes in some tabs, it is very convenient to directly enter the code:

onReachBottom() {        let isPush = this.data.index,
            val = this.data.inputVal;
        this.setData({
            isBtnShow: true
        });        if (isPush ==1) {            let num = this.data.limitIndex;
            this.setData({                limitIndex: num+1
            })
        //关于上拉加载的性能优化            setTimeout(()=>{
                    // 给后端传下拉刷新的次数+1
                    const data = {                        limitIndex: this.data.limitIndex
                    };
                    utils.sendRequest(api.AllGoodsUrl, data, this.handleReachBottom.bind(this));
            },1500)
        };        if (val != '') {            setTimeout(()=>{                let num = this.data.limitIndex;
                    this.setData({                        limitIndex: num+1
                    })
                    // 给后端传下拉刷新的次数+1
                    const data = {                        limitIndex: this.data.limitIndex,
                         data:{
                            name: this.data.inputVal,
                        }
                    };
                    utils.sendRequest(api.AllGoodsUrl, data, this.handleLoadMore.bind(this));
            },1500)
        };
    },
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to use switchTab in WeChat applet development

JS implements statistics on data patterns within strings

The above is the detailed content of How to implement pull-up loading in WeChat applet development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!