收藏
回答

windows下实时数据推送?

以下代码用实时数据推送,在微信开发者工具及手机端都能正常稳定运行。

但在Windows的环境下,当isClosedLoop = true正常运行,但当isClosedLoop = false则报错,不知道什么原因?

代码:

      let isClosedLoop
      if (that.data.currentTabs == 'processing') {
        isClosedLoop = false
      } else {
        isClosedLoop = true
      }


      const db = wx.cloud.database()
      const _ = db.command


      console.log('[需求列表] : 开始监听')
      const watcher = db.collection('support').orderBy('createTime', 'desc').limit(that.data.supportListLimit)
        .where(_.and({
          closedLoop: isClosedLoop
        }, _.or({
          frontlineOpenId: that.data.loginInfo.staffOpenId
        }, {
          supportOpenId: that.data.loginInfo.staffOpenId
        })))
        .watch({
          onChange: function (snapshot) {
            console.log(snapshot)
          },
          onError: function (err) {
            console.error('the watch closed because of error', err)
          }
        })


在Windows的环境下,当isClosedLoop = false报错:

thirdScriptError
[realtime] onMessage parse res.data error: SyntaxError: Unexpected token o in JSON at position 1;at socketTask.onmessage callback function
Error: [realtime] onMessage parse res.data error: SyntaxError: Unexpected token o in JSON at position 1
at n.Bi.onSocketMessage (file://6.js/:2:508995)
at n.e (file://6.js/:2:260063)
at i. (file://6.js/:2:128008)
at i.emit (file://6.js/:2:615034)
at file://6.js/:2:1311903
at file://6.js/:2:607765
at Object.m (file://6.js/:2:77725)
at file://199.js/:1:57


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

1 个回答

登录 后发表内容
问题标签