小程序 : 请求,数据,事件,上拉加载下拉刷新

// pages/profile/profile.js
Page({
 //数据 data: { avatarURL:
"", listCount: 30 }, // 监听下拉刷新 onPullDownRefresh() { console.log("用户进行下拉刷新~"); // 模拟网络请求: 定时器 setTimeout(() => { this.setData({ listCount: 30 }) // API: 停止下拉刷新 wx.stopPullDownRefresh({ success: (res) => { console.log("成功停止了下拉刷新", res); }, fail: (err) => { console.log("失败停止了下拉刷新", err); } }) }, 1000) }, // 监听页面滚动到底部 onReachBottom() { console.log("onReachBottom"); this.setData({ listCount: this.data.listCount + 30 }) } })
<!--pages/profile/profile.wxml-->
<text>pages/profile/profile.wxml</text>

<view class="list">
  <block wx:for="{{listCount}}" wx:key="*this">
    <view>列表数据:{{ item }}</view>
  </block>
</view>
{
  "usingComponents": {},
  "navigationBarTitleText": "个人信息",
  "navigationBarBackgroundColor": "#f00",
  "enablePullDownRefresh": true,
  "onReachBottomDistance": 100
}

 

posted @ 2022-09-07 11:05  杨建鑫  阅读(23)  评论(0编辑  收藏  举报