m***@163.com
m***@163.com
  • 发布:2024-11-27 14:16
  • 更新:2024-11-27 14:16
  • 阅读:603

鸿蒙Next 小程序sdk registerModule如何注册异步方法

分类:鸿蒙Next

按照文档: https://nativesupport.dcloud.net.cn/UniMPDocs/Extension/harmony.html

export default {  
  test: (a: number, b: number): number => {  
    return a + b;  
  }  
} as ESObject

可以注册 同步的方法 test

如何注册异步的方法并进行调用

2024-11-27 14:16 负责人:无 分享
已邀请:
m***@163.com

m***@163.com (作者)

安卓中注册 异步方法:

//run ui thread  
@UniJSMethod(uiThread = true)  
public void testAsyncFunc(JSONObject options, UniJSCallback callback) {  
    Log.e(TAG, "testAsyncFunc--"+options);  
    if(callback != null) {  
        JSONObject data = new JSONObject();  
        data.put("code", "success");  
        callback.invoke(data);  
    }  
}

要回复问题请先登录或注册