const app = getApp()
var musicwatcher = null
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const db = wx.cloud.database()
this.musicwatcher = db.collection('notify').where({
notifyType: 1,
notifyOpenid: 'oo7SZ5A-B8MS6WWJzsZ2RF8DXEio',
}).watch({
onChange: function (snapshot) {
if (snapshot.docChanges.length) {
app.globalData.visitorNumber = snapshot.docChanges.length
}
},
onError: function (err) {
console.error('the watch closed because of error', err)
}
})
}
是我的写法有什么问题吗?
得改一下数据权限
这样写,