小程序最基本的上划加载数据

2019-01-28  本文已影响8人  飘渺的心意
<scroll-view scroll-y="true" bindscrolltolower="scrollEvent" style='height:1336rpx;'>
        这里有很多电影数据。。。
</scroll-view>

处理方法

刷新的个数
var offset = 0; 

onLoad: function (options) {
    保证每次点进去都能下拉刷新
    offset = 0;
    this.requests('http://localhost:8888/movies/')
},


下滑滚动事件
scrollEvent: function(event){
    offset += 9;
    this.requests("http://localhost:8888/movies/")
},


requests(url) {
    let self = this;
    wx.request({
        url: url,
        method: "GET",
        success: function (response) {
            self.setData({
                movies: response.data.slice(0, offset+9)  offset为刷新的个数
            })
        }
    })
},
上一篇 下一篇

猜你喜欢

热点阅读