当我写这个
var ref = Cloud.collection('Groups').doc(Option)
.collection('India').doc('Info')
ref.get().then(function(fields){
var data = fields.data()
alert(data)
totalposts = data.TotalPosts
alert('totalposts : ' + totalposts)
postnum = totalposts + 1;
alert('postnum : ' + postnum)
})
它工作得非常好但是当我这样做时: -
var abc = 'India'
var ref = Cloud.collection('Groups').doc(Option)
.collection(abc).doc('Info')
ref.get().then(function(fields){
var data = fields.data()
alert(data)
totalposts = data.TotalPosts
alert('totalposts : ' + totalposts)
postnum = totalposts + 1;
alert('postnum : ' + postnum)
它说未定义并给我一个错误我被困6个小时而且真的很难过请帮帮我
Unhandled Rejection (TypeError): Cannot read property 'TotalPosts' of undefined