t***@163.com
t***@163.com
  • 发布:2025-04-10 22:14
  • 更新:2025-04-10 22:18
  • 阅读:79

云对象中有两个方法,无法互相调用

分类:uniCloud

产品分类: uniCloud/App

操作步骤:
// 云对象教程: 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打印'1234'

实际结果:

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

2025-04-10 22:14 负责人:无 分享
已邀请:
BoredApe

BoredApe - 有问题就会有答案。

  • t***@163.com (作者)

    非常感谢,原来对象中的方法无法互相调用

    2025-04-15 23:17

要回复问题请先登录注册