问题
使用云函数获取云数据库的数据时,发现json对象没有赋值前打印出来是正常的,但是赋值之后打印出来就变成了如下:
{
"affectedDocs": 2,
"data": [{
"__ob__": {
"dep": {
"id": 672,
"subs": [{
"active": true,
"before": "function before () {\n if (vm._isMounted && !vm._isDestroyed) {\n callHook(vm, 'beforeUpdate');\n }\n }",
"cb": "function noop (a, b, c) {}",
"deep": false,
"depIds": "Object",
"deps": "Object",
"dirty": false,
"expression": "function () {\n vm._update(vm._render(), hydrating);\n }",
"getter": "function () {\n vm._update(vm._render(), hydrating);\n }",
"id": 121,
"lazy": false,
"newDepIds": "Object",
"newDeps": "Object",
"sync": false,
"user": false,
"vm": "Object"
}]
},
"value": {
"__ob__": {
"dep": {
"id": 672,
"subs": "Object"
},
"value": {
"__ob__": "Object"
},
"vmCount": 0
}
},
"vmCount": 0
}
}, {
"__ob__": {
"dep": {
"id": 686,
"subs": [{
"active": true,
"before": "function before () {\n if (vm._isMounted && !vm._isDestroyed) {\n callHook(vm, 'beforeUpdate');\n }\n }",
"cb": "function noop (a, b, c) {}",
"deep": false,
"depIds": "Object",
"deps": "Object",
"dirty": false,
"expression": "function () {\n vm._update(vm._render(), hydrating);\n }",
"getter": "function () {\n vm._update(vm._render(), hydrating);\n }",
"id": 121,
"lazy": false,
"newDepIds": "Object",
"newDeps": "Object",
"sync": false,
"user": false,
"vm": "Object"
}]
},
"value": {
"__ob__": {
"dep": {
"id": 686,
"subs": "Object"
},
"value": {
"__ob__": "Object"
},
"vmCount": 0
}
},
"vmCount": 0
}
}]
解决办法
事实上这个是vue的ob: Observer这些数据是vue这个框架对数据设置的监控器。不能够直接打印但是也是可以获取数据的
const va = uniCloud.importObject("getques")
const ans = await va.getList()
this.res = ans.data//给本地的res对象赋值
console.log(ans)//这样打印出来就是如上代码一样是看不到数据的
console.log(this.res.data[0].que)//这样打印就可以打印出正常的数据了打印结果是
其实可以正常操作了,在v-for中遍历
得到结果
0 个评论
要回复文章请先登录或注册