当前位置: 首页 > 工具软件 > CommonEvent > 使用案例 >

HarmonyOS应用API-CommonEvent.publish

熊嘉茂
2023-12-01

Api:  CommonEvent.publish

版本适配:Api7

作用:发布公共事件

示例代码:

//发布公共事件回调
function PublishCallBack(err) {
    if (err.code) {
        console.error("publish failed " + JSON.stringify(err));
    } else {
        console.info("publish");
    }
}

//发布公共事件
CommonEvent.publish("event", PublishCallBack);

 类似资料: