// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module.exports = {
async test1(){
console.log(this.test2())
},
test2(){
return '1234'
}
}

- 发布:2025-04-10 22:14
- 更新:2025-04-10 22:18
- 阅读:79
产品分类: uniCloud/App
操作步骤:
预期结果:
调用test1打印'1234'
调用test1打印'1234'
实际结果:
TypeError: this.test2 is not a function
TypeError: this.test2 is not a function
bug描述:
写了最简单的云对象,test1方法想要调用test2方法,但是报错TypeError: this.test2 is not a function
// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module.exports = {
async test1(){
console.log(this.test2())
},
test2(){
return '1234'
}
}
运行test1报错:
TypeError: this.test2 is not a function

BoredApe - 有问题就会有答案。
请参考文档:https://doc.dcloud.net.cn/uniCloud/cloud-obj.html#call-by-cloud
const login = uniCloud.importObject('login-manager')
const res = await login.test2()
t***@163.com (作者)
非常感谢,原来对象中的方法无法互相调用
2025-04-15 23:17