实时数据的watch方法报错,是什么原因?
发布于 5 年前 作者 weiren 10754 次浏览 来自 官方Issues

代码

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 回复

基础库2.8.1

为什么不是一个函数

回到顶部