wxml
<scroll-view bindscrolltolower="lower" scroll-y style="height:100vh;"> </scroll-view>
记得将app.wxss的page高度设为100vh
page{
height:100vh
}js lower() {
that.getData(); //加载更多数据
},为了防止拖动下来后疯狂的加载数据,我们可以增加一个函数节流
在utils目录中新建util.js,内容如下:
function throttle(fn, gapTime) {
if (gapTime == null || gapTime == undefined) {
gapTime = 1500
}
let _lastTime = null
// 返回新的函数
return function () {
let _nowTime = + new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments) //将this和参数传给原函数
_lastTime = _nowTime
}
}
}
module.exports = {
throttle: throttle
}改造一下jsconst util = require('../../utils/util.js')
Page({
onLoad: function (options) {
},
lower() {
var that=this;
util.throttle(function (e) {
that.getData(); //加载更多数据
}, 2000)
},
})这样就控制在2秒内只能执行一次getdata函数
网友回复
linux stream如何限制单个目录最大容量?
哪有免费的千问qwen3.6-plus的api可以使用?
python如何自动根据视频图片等素材自动按照要求剪辑视频生成剪映草稿?
gemma4与开源的qwen3.5哪个更厉害?
wan2.7 video与seedance2哪个更好?
claude code 51万行代码泄露被迫开源在哪能找到源码?
有没有免费的虚拟局域网工具可以将互联网设备组成一个大的局域网?
全球顶尖大模型这么强,为啥AGI 测试集体溃败 人类满分 AI 最高仅 0.37%?
听说字节seedance3的视频生成长度可达到10分钟?
谷歌的TurboQuant是不是真的?


