diff --git a/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md b/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md index 18c71554d9f31d46a0784378aa8882310b5c0e12..6a7b166b54a72d5a003dbf05a0823de21665bd73 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md @@ -68,7 +68,8 @@ getPixelMap(): image.PixelMap; **示例:** ```ts -pixmap: PixelMap = drawable1.getPixelMap(); +pixmap: PixelMap = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') + .id))).getPixelMap(); ``` ## LayeredDrawableDescriptor.getPixelMap @@ -86,7 +87,8 @@ getPixelMap(): image.PixelMap; **示例:** ```ts -pixmap: PixelMap = layeredDrawable1.getPixelMap(); +pixmap: PixelMap = (( (this.resManager.getDrawableDescriptor($r('app.media.icon') + .id))).getForeground()).getPixelMap(); ``` ## LayeredDrawableDescriptor.getForeground @@ -104,7 +106,8 @@ getForeground(): DrawableDescriptor; **示例:** ```ts -drawable: DrawableDescriptor = layeredDrawable1.getForeground(); +drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') + .id))).getForeground(); ``` ## LayeredDrawableDescriptor.getBackground @@ -122,7 +125,8 @@ getBackground(): DrawableDescriptor; **示例:** ```ts -drawable: DrawableDescriptor = layeredDrawable1.getBackground(); +drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') + .id))).getBackground(); ``` ## LayeredDrawableDescriptor.getMask @@ -140,5 +144,6 @@ getMask(): DrawableDescriptor; **示例:** ```ts -drawable: DrawableDescriptor = layeredDrawable1.getMask(); +drawable: DrawableDescriptor = ( (this.resManager.getDrawableDescriptor($r('app.media.icon') + .id))).getMask(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md b/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md index 995ce9d9331bb7093f757544aa9d251f5cbe39eb..76ec3862c61789a3e8f9d4b94b959edb819fd891 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md @@ -376,10 +376,24 @@ on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback ): | eventType | string | 是 | 监听的事件类型, 可选值为:"push" 、"request"。
"push”:指组件提供者向使用者主动推送数据。
"request”:指组件使用者向提供者主动请求数据。 | | callback | [OnPushEventCallback](#onpusheventcallback) \| [OnRequestEventCallback](#onrequesteventcallback) | 是 | 对应监听回调,push事件对应回调类型为[OnPushEventCallback](#onpusheventcallback),request事件对应回调类型为[OnRequestEventCallback](#onrequesteventcallback) 。 | - **示例:** ```js +function onPushListener(source, template, data, extraData) { + console.log("onPushListener template.source=" + template.source) + console.log("onPushListener source=" + JSON.stringify(source)) + console.log("onPushListener template=" + JSON.stringify(template)) + console.log("onPushListener data=" + JSON.stringify(data)) + console.log("onPushListener extraData=" + JSON.stringify(extraData)) +} +function onRequestListener(source, name, data) { + console.error("onRequestListener"); + console.log("onRequestListener source=" + JSON.stringify(source)); + console.log("onRequestListener name=" + name); + console.log("onRequestListener data=" + JSON.stringify(data)); + + return { template: "ets/pages/plugin.js", data: data }; +} pluginComponentManager.on("push", onPushListener) pluginComponentManager.on("request", onRequestListener) ```