2***@qq.com
2***@qq.com
  • 发布:2024-09-08 16:14
  • 更新:2024-09-12 18:33
  • 阅读:53

Cannot assign to read only property '0' of string

分类:uniCloud

在云对象中有下面的代码

const db = uniCloud.database();

module.exports = {
_before: function() { // 通用预处理器
this.startTime = Date.now()
this.params = this.getParams()
},

async getResourceFile() {  

    const res = await db.collection('tb_material')  

        .where({  
            position: 1  
        })  
        .field("_id,title")  
        .get()  
    return {  
        errCode: 0,  
        errMsg: "查询成功",  
        data: res.data  
    }  
}  

}

正常的从数据库查询数据 报错 TypeError: Cannot assign to read only property '0' of string '_id,title'

const res = await db.collection('tb_material')
.where({
position: 1
})
.get()
如果不添加 field字段,代码可以正常执行 这是为什么啊 找了好长时间的问题了

2024-09-08 16:14 负责人:DCloud_uniCloud_VK 分享
已邀请:
DCloud_uniCloud_VK

DCloud_uniCloud_VK

要回复问题请先登录注册