
如图,当点击按钮后,清空输入框内容,代码中that.setData({
startpoint:'',
goal:''
})时,上拉加载更多失效,请问当点击按钮后,清空输入框内容,又不影响上拉加载更多功能
wxml代码:
<view class="search-input-group">
<view class="input-group">
<input class="search-input" placeholder="出发地" value="{{startPoint}}" bindinput="onStartPointEvent" />
<image class="thumbnail" src="../../images/return.png" />
<input class="search-input" placeholder="终点" value="{{goal}}" bindinput="onGoalEvent" />
</view>
<button class="search-button" size="mini" bindtap="onchaxun">查询</button>
</view>
js代码:
data: {
hasmore: true,
startPoint:'',
goal: '',
isQuerying: false,
},
/**
* 获取起点输入信息
*/
onStartPointEvent(event) {
const that = this;
const startPoint = event.detail.value
console.log('起点', startPoint);
that.setData({
startPoint: startPoint
})
},
/**
* 获取终点输入信息
*/
onGoalEvent(event) {
const that = this;
const goal = event.detail.value
console.log('终点', goal);
that.setData({
goal: goal
})
},
/**
* 按条件查询数据
*/
async onchaxun(start = 0) {
// console.log(event);
const that = this;
that.setData({
isQuerying: true,
})
let promite = db.collection("wehicle").where({
startPoint: that.data.startPoint,
goal: that.data.goal,
})
if(start>0){
promite = promite.skip(start)
}
let pro = await promite.limit(2).orderBy('create_time','desc').get()
console.log(pro)
if(pro){
const sumlistress = pro.data;
console.log(sumlistress);
promite.count().then(res => {
console.log(res)
that.setData({
result:res.total
})
})
let hasmore = false
let newsumlistress = [];
if (start > 0) {
newsumlistress = that.data.sumlistress.concat(sumlistress);
} else {
newsumlistress = sumlistress;
}
newsumlistress.forEach((wehicle, index) => {
wehicle.create_time = wehicle.create_time.toString();
})
that.setData({
sumlistress: newsumlistress,
hasmore: hasmore,
startPoint: '',这样写会让上拉加载更多失效
goal: '',
})
}
}