美文网首页
小程序最基本的上划加载数据

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

作者: 飘渺的心意 | 来源:发表于2019-01-28 12:47 被阅读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为刷新的个数
            })
        }
    })
},

相关文章

网友评论

      本文标题:小程序最基本的上划加载数据

      本文链接:https://www.haomeiwen.com/subject/mpkajqtx.html