建立了一个云对象文件,该对象中只有一个简单方法返回数据
module.exports = {
_before: function() { // 通用预处理器
},
async getCategory() {
// const db = uniCloud.database();
// let list = await db.collection('category').where({
// enable: true,
// pid: '0'
// }).get();
return [{id:"11",name:"sss"}];
}
}
页面调用:
async getCategory(){
let that=this;
try{
let proObj=uniCloud.importObject("product")
let obj= await proObj.getCategory();
console.log("resresresres",obj);
const arr=obj;
console.log("arr",arr);
this.list=arr
console.log("this.list",this.list);
}
catch(e){
//TODO handle the exception
console.log("发生错误");
}
},
然后在页面中调用云对象的该方法,拿到数据赋值,赋值后返回的数据被改变了,打印如下
- 当我不使用
this.xxx=obj
赋值时,正确打印数据
14:19:09.322 resresresres [{"id":"11","name":"sss"}] at pages/diancan/diancan.vue:143
14:19:09.332 arr [{"id":"11","name":"sss"}] at pages/diancan/diancan.vue:145
-
当我使用
this.xxx=obj
赋值时,值被改变了14:20:23.426 resresresres [{"__ob__":{"dep":{"id":111623,"subs":[]},"value":{"__ob__":{"dep":{"id":111623,"subs":[]},"value":{"__ob__":{"dep":"Object","value":"Object","vmCount":0}},"vmCount":0}},"vmCount":0}}] at pages/diancan/diancan.vue:143 14:20:23.434 arr [{"__ob__":{"dep":{"id":111623,"subs":[]},"value":{"__ob__":{"dep":{"id":111623,"subs":[]},"value":{"__ob__":{"dep":"Object","value":"Object","vmCount":0}},"vmCount":0}},"vmCount":0}}] at pages/diancan/diancan.vue:145 14:20:23.440 this.list [{"__ob__":{"dep":{"id":111623,"subs":[]},"value":{"__ob__":{"dep":{"id":111623,"subs":[]},"value":{"__ob__":{"dep":"Object","value":"Object","vmCount":0}},"vmCount":0}},"vmCount":0}}] at pages/diancan/diancan.vue:147
环境:
hbuilderx :3.6.4
1 个回复
DCloud_uniCloud_WYQ
这个是vue添加的,不影响你正常访问里面的数据