收藏
回答

实时数据的watch方法报错,是什么原因?


代码

const db = wx.cloud.database()const watcher = db.collection('todos').where({
  team: 'our dev team'}).watch({
  onChange: function(snapshot) {
    console.log('docs\'s changed events', snapshot.docChanges)
    console.log('query result snapshot after the event', snapshot.docs)
    console.log('is init data', snapshot.type === 'init')
  },
  onError: function(err) {
    console.error('the watch closed because of error', err)
  }})watcher.close()

运行报这个错db.collection(...).where(...).watch is not a function;at "pages/loging/loging" page lifeCycleMethod onLoad function

TypeError: db.collection(...).where(...).watch is not a function

    at ye.onLoad ()

    at ye.<anonymous> (WAService.js:1:1315997)

    at ye.p.__callPageLifeTime__ (WAService.js:1:1315742)

    at Ct (WAService.js:1:1330692)

    at WAService.js:1:1333863

    at At (WAService.js:1:1334356)

    at Function.<anonymous> (WAService.js:1:1337746)

    at i.<anonymous> (WAService.js:1:1307261)

    at i.emit (WAService.js:1:417150)

    at Object.emit (WAService.js:1:576442)


回答关注问题邀请回答
收藏

2 个回答

  • 老张
    老张
    2019-11-25

    基础库2.8.1

    2019-11-25
    有用 1
    回复 2
    • 轩
      2019-11-25
      怎么弄,大哥可以教教吗,谢了
      2019-11-25
      回复
    • 轩
      2019-11-25
      可以了,感谢提醒
      2019-11-25
      回复
  • 轩
    2019-11-24

    为什么不是一个函数


    2019-11-24
    有用
    回复
登录 后发表内容
问题标签