小程序下拉刷新无效的问题解决

3,299 阅读1分钟

在小程序pages/index页面要实现下拉刷新

wxml

  <!--wxml结构-->
  <view class="boxer">
    
  </view>

wxss (sylus语法)

.boxer
  width 100vw
  height 100vh

index.js

Page({
    onPullDownRefresh: function(){
        console.log('=========== 11111')
    }
})

app.json

{
    "window": {
      "enablePullDownRefresh":true
    },
}

index.json

{
  "enablePullDownRefresh": true,
}

以上代码参考官方及百度其他的解决方案,但我在开发模拟器及预览均不能触发onPullDownRefresh方法,不能实现下拉刷新。最终问题定位为CSS样式设置不当造成上述问题

原wxss设置

.boxer
  width 100vw
  height 100vh

改为

.boxer
  width 100vw
  height 100%

问题解决