在使用scroll-view組件下拉加載分頁數(shù)據(jù),發(fā)現(xiàn)bindscrolltolower 沒有觸發(fā),原因是:scroll-view 元素的高度必須是設(shè)備的高度,單位且必須是px ,詳情實現(xiàn)如下:
1 index.wxml添加scroll-view 組件
<scroll-view scroll-y="true" bindscrolltolower="loadInformations" style="height:{{scrollH}}px" scroll-into-view="allInformation" data-type="allInformation">
<view id="allInformation" class="section section-big">
<import src="../template/informationList.wxml" />
<template is="informationList" data="{{informations}}"></template>
</view>
</scroll-view>
重點是:style="height:{{scrollH}}px"
2 index.js 的onLoad 事件中 賦值scrollH
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
scrollH:0
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function (options) {
var self = this;
wx.getSystemInfo({
success: function(res) {
let scrollH = res.windowHeight;
self.setData({
scrollH:scrollH
});
}
});
}
})
3 在loadInformations 事件中加載分頁數(shù)據(jù)