VM2713 WAService.js:2 TypeError: Cannot read property ‘todoList_nums‘ of undefined

下面是我的js代码,第一次查询可以正常获取20条,但是下拉刷新就不行。。不知道为啥,求大神指导。。。
const app = getApp()
const db = wx.cloud.database({
env: ‘nxdcs-service’
})

Page({
data: {
CRH: “”,
name: “”,
BSTPN: “”,
SupplierPN: “”,
local: “”,
tools: “”,
searchContent: “”,
todoList: [],//查询结果
todoList_nums:0 //初始数量
},
//监听input输入
watchName: function (e) {
var that = this
that.setData({
name: e.detail.value
});

},

queryTodoList() {

//测试一下能不能用
const db = wx.cloud.database()
db.collection('797').where({
  name: db.RegExp({
    regexp: this.data.name,
    options: 'i',
  })
}).get({
  success: res => {
    this.setData({
      todoListFetched: true,
      todoList: res.data,
      filtered: true
    })
    console.log('[数据库] [查询记录] 成功: ', res)
  },
  fail: err => {
    wx.showToast({
      icon: 'none',
      title: '查询记录失败'
    })
    console.error('[数据库] [查询记录] 失败:', err)
  },
  complete: () => {
    wx.hideLoading()
  }
})

},
onReachBottom:function(){
wx.showLoading({
title: ‘刷新中,请稍等!’,
duration:1000
})
let x=this.date.todoList_nums+20
console.log(x)
let old_date=this.date.todoList
db.collection(‘797’).where({
name: db.RegExp({
regexp: this.data.name,
options: ‘i’,
})
}).skip(x)
.get()
.then( res => {
res.date.array.forEach((item,i) => {
res.date[i].content=res.data[i].content.split(‘hy’).join(’\n’);
});
// 利用concat函数连接新数据与旧数据
// 并更新emial_nums
this.setData({
todoList: old_data.concat(res.data),
todoList_nums: x
})
console.log(res.data)
})
.catch(err => {
console.error(err)
})
console.log(‘circle 下一页’);

},

goSet: function () {
wx.navigateTo({
url: ‘…/set797/set797’,
})

},
searchTodo() {
const { searchContent } = this.data
if (!searchContent) {
this.queryTodoList()
return
}}

})

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值