小程序端,利用watch监听不到数据?
发布于 4 年前 作者 tdai 1546 次浏览 来自 问答
Page({

  data:{
    blocks: []
  },

  watcher:{},

  onReady: function () {
    let that = this
    db.collection('test').where({
      reqId: _.eq(reqId)
    }).orderBy('isAuthor','desc').get()
    .then(res => {
      that.setData({
        blocks: res.data
      })
    }).catch(err => {
        console.error(err)
    })
  },

  onShow: function () {
    console.log('onShow')
    this.watcher = db.collection('test').where({
      reqId: this.data.reqObj.reqId
    }).orderBy('isAuthor','desc').watch({
      onChange: function(res){
        console.debug(JSON.stringify(res))
      },
      onError: function(err){ }
    })
  },
})

数据库权限已经开启

监听后,操作数据库中的监控数据,小程序端没有任何反应,请问怎么处理?

回到顶部