以下代码用实时数据推送,在微信开发者工具及手机端都能正常稳定运行。
但在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
请具体描述问题出现的流程,并提供pc微信版本号,window系统信息,能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
我现在将布尔值改为了数字0和1,问题解决。
这应该是一个bug。