收藏
回答

页面下拉刷新,开发工具上可以,但真机预览就不行?

微信版本:7.0.13,机型:小米手机 红米note8,系统版本miui 11,

wxss

.image{
  width: 100%;
  height: 100vh;
  background-color: rgba(0,0,0,.2);
}


.review{
  position: absolute;
  left: 60rpx;
  right: 0;
  top: 10%;
  line-height: 60rpx;
  text-align: center;
  z-index: 900;
}

wxml

<image class="image" mode="scaleToFill" src='../../images/35359631.jpg'></image>
<text class="review">{{currentText}}</text>

json

{
  "enablePullDownRefresh": true,
  "backgroundTextStyle": "dark"
}

js

  onPullDownRefresh () {
    this.loadMore()
    wx.stopPullDownRefresh()
  },
回答关注问题邀请回答
收藏

2 个回答

  • o0o有脾气的酸奶
    o0o有脾气的酸奶
    2020-04-26
    loadMore: function(){
      return new Promise((rs, rj)=>{
        wx.request({
          ...,
          success(res){
            rs(res.data||{})
          },
          fail(e){
            rj(e||{})
          }
        })
      })
    },
    onPullDownRefresh () {
      var t = this
      this.loadMore().then(res=>{
        // res为请求到的数据
        t.setData({
          .....
        })
      }).catch(e=>{
        console.error(e)
      }).finally(()=>{
        // 不管错误还是成功最后都会执行wx.stopPullDownRefresh()
        wx.stopPullDownRefresh()
      })
    },
    

    若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人

    2020-04-26
    有用 1
    回复 9
    查看更多(4)
  • A黑色低调
    A黑色低调
    2020-04-25
    loadMore 数据获取成功之后  再用 wx.stopPullDownRefresh()
    

    

    2020-04-25
    有用
    回复 2
    • 熊晨辉
      熊晨辉
      2020-04-26
      不是这个原因,调试下拉根本就没有进入onPullDownRefresh,更谈不上后面的stopPullDownRefresh
      2020-04-26
      回复
    • Copy
      Copy
      2021-04-21回复熊晨辉
      老哥解决了没?我也遇到这个问题了
      2021-04-21
      回复
登录 后发表内容
问题标签