下拉刷新如图,模拟器正常,真机上不回弹。上拉加载,切换到其他页面时,如果没有数据或者上拉的动作,就一直显示加载中,这问题怎么解决,求助大佬
wxml代码
<view class="carpool-title">
<text class="title-text">百姓同城拼车网-同城拼车</text>
</view>
<view class="ad-group">
<image class="ad-image" src="../../images/专注.jpg" mode="" />
</view>
<view class="search-input-group">
<view class="input-group">
<input class="search-input" placeholder="出发地" />
<image class="thumbnail" src="../../images/return.png" mode="" />
<input class="search-input" placeholder="终点" />
</view>
<button class="search-button" size="mini">查询</button>
</view>
<segment-carpool items="{{items}}" wehicle="{{wehicle}}" binditemchengde="onItemChengdeEvent" defaultIndex="0">
<view slot="0" class="segment-page wehicle-page">
<wehicle wx:for="{{wehicles}}" wx:key="wehicle" wx:for-item="wehicle" wehicle="{{wehicle}}"></wehicle>
</view>
<view slot="1" class="segment-page people-page">
<wehicle wx:if="{{wehicle.carpool == '我要找车'}}" wx:for="{{wehicles}}" wx:key="wehicle" wx:for-item="wehicle" wehicle="{{wehicle}}"></wehicle>
</view>
<view slot="2" class="segment-page train-page">
<wehicle wx:if="{{wehicle.carpool == '我要找人'}}" wx:for="{{wehicles}}" wx:key="wehicle" wx:for-item="wehicle" wehicle="{{wehicle}}"></wehicle>
</view>
<view slot="3" class="segment-page money-page">
<wehicle wx:if="{{wehicle.carpool == '我找货车'}}" wx:for="{{wehicles}}" wx:key="wehicle" wx:for-item="wehicle" wehicle="{{wehicle}}"></wehicle>
</view>
<view slot="4" class="segment-page money-page">
<wehicle wx:if="{{wehicle.carpool == '我要找货'}}" wx:for="{{wehicles}}" wx:key="wehicle" wx:for-item="wehicle" wehicle="{{wehicle}}"></wehicle>
</view>
</segment-carpool>
<loadingmore hasmore="{{hasmore}}"></loadingmore>
JS代码
const db = wx.cloud.database();
Page({
data: {
items:["全部","我要找车","我要找人","我找货车","我要找货"],
hasmore:true,
wehicles:[],
},
onLoad(options) {
},
onItemChengdeEvent(event){
},
lowdrelease(start=0){
const that = this;
let promise = db.collection("wehicle");
if(start>0){
promise = promise.skip(start);
}
promise.limit(10).orderBy("create_time", "desc").get().then(res => {
const wehicles = res.data;
let hasmore = true;
if(wehicles.length == 0){
hasmore = false
}
let newWehicles = [];
if(start > 0){
newWehicles = that.data.wehicles.concat(wehicles);
}else{
newWehicles = wehicles;
}
that.setData({
wehicles:newWehicles,
hasmore:hasmore
})
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.lowdrelease();
wx.stopPullDownRefresh();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.lowdrelease(0);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
this.lowdrelease(this.data.wehicles.length);
},
})
接口回调之后,不管有数据还是没有数据,都执行一下stopPullDownRefresh, 这一块的调试开发者工具可能有问题, 还是以真机效果为准,参考真机的效果。
不是,反了,你理解一下stoppull
理解一下那个方法是干什么的