收藏
回答

小程序端,利用watch监听不到数据?

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){ }
    })
  },
})

数据库权限已经开启

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

最后一次编辑于  2021-01-15
回答关注问题邀请回答
收藏

1 个回答

  • Monster
    Monster
    2021-05-25

    小程序没有watch 属性

    2021-05-25
    有用
    回复
登录 后发表内容
问题标签