【求助】有大佬使用过HarmonyOS鸿蒙Next新修改后的cloudFunction云函数模块吗?

【求助】有大佬使用过HarmonyOS鸿蒙Next新修改后的cloudFunction云函数模块吗?

cke_166.png

SDK中没有讲明白是否需要初始化等内容, 然后按照里面示例代码使用时,应用会直接闪退,并报错Cannot read property call of undefined。下面是错误的信息,但是我没有查到相关的内容可以用来排查问题

Device info:emulator
Build info:emulator 5.0.0.65(SP73DEVC00E65R4P11log)
Fingerprint:8318875a6ebe8c12f069c3a1b901d47acf0fd0a34e58c3e17b955191932adcc7
Module name:com.itheima.mytest
Version:1.0.0
VersionCode:1000000
PreInstalled:No
Foreground:Yes
Pid:6016
Uid:20020041
Reason:TypeError
Error name:TypeError
Error message:Cannot read property call of undefined
Stacktrace:
    at anonymous (entry/src/main/ets/pages/Student_Page.ets:24:11)

下面是代码文件:

import { Student } from '../Model/Student';
import { cloudFunction, cloudCommon } from '@kit.CloudFoundationKit';
import { BusinessError, request } from '@kit.BasicServicesKit';
import { JSON } from '@kit.ArkTS';

@Entry
@Component
struct Student_Page {
  @State message: string = 'Hello World';

  build() {
    Column() {
      Text(this.message)
        .fontSize(20)
      Button("查询数据")
        .width("80%")
        .margin({ top: 20 })
        .onClick(() => {
          cloudFunction.call({
            name: "query-student-function",
          }, (err: BusinessError, data: cloudFunction.FunctionResult) => {
            if (err) {
              console.error(`Failed to call the function, Code: ${err.code}, message: ${err.message}`);
              return;
            }
            console.info(`Succeeded in call the function, result: ${data.result.toString()}`);
          })
        })
      Button("删除一条数据")
        .width("80%")
        .margin({ top: 20 })
    }
    .height('100%')
    .width('100%')
  }
}

因为我在使用上个版本的时候,是需要初始化,然后通过 import cloud from '@hw-agconnect/cloud' 的cloud.callFunction方法来调用的,新的就不行了。

有大佬推荐一下相关的文章吗?或者解决方法


更多关于【求助】有大佬使用过HarmonyOS鸿蒙Next新修改后的cloudFunction云函数模块吗?的实战教程也可以访问 https://www.itying.com/category-93-b0.html

9 回复

更多关于【求助】有大佬使用过HarmonyOS鸿蒙Next新修改后的cloudFunction云函数模块吗?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


找到问题了,模拟器中不支持云函数的调用

cke_168.png

这不涉及任何硬件的东西,为什么模拟器不支持呢?

请问楼主解决了吗,我也是同样的问题

只能用回旧版本的方法,可以看看我新的帖子。

要在EntryAbility初始化AGC的,

要在EntryAbility初始化AGC的,

期待HarmonyOS能在未来推出更多针对企业用户的解决方案。

bate1版本的也是需要的吗?我看到文档里面是没有初始化这一步了。我记得之前是有的,

HarmonyOS鸿蒙Next的cloudFunction云函数模块经过优化,提供了更高效的云端计算能力。新版本增强了与本地设备的协同能力,支持更复杂的业务逻辑处理。开发者可以通过简单的API调用实现云端功能,同时享受更低的延迟和更高的安全性。建议查阅官方文档以获取详细的使用指南和最佳实践。

回到顶部