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 dad78c6fad1f8a8114ab5d487f298f6add5ad09d..ada7897303b8676a5c80336a3d4a761674240deb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md @@ -155,11 +155,11 @@ OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KV ```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)) + 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)) } ``` @@ -181,14 +181,13 @@ OnRequestEventCallback = (source: Want, name: string, data: KVObject) => Request **示例:** ```js -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)); +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}; + return { template: "ets/pages/plugin.js", data: data }; } ``` @@ -210,24 +209,24 @@ push(param: PushParameters , callback: AsyncCallback<void>): void ```js pluginComponentManager.push( -{ + { want: { - bundleName: "com.example.provider", - abilityName: "com.example.provider.MainAbility", + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", }, name: "plugintemplate", data: { - "key_1": "plugin component test", - "key_2": 34234 + "key_1": "plugin component test", + "key_2": 34234 }, extraData: { - "extra_str": "this is push event" + "extra_str": "this is push event" }, jsonPath: "", - }, - (err, data) => { - console.log("push_callback: push ok!"); - } + }, + (err, data) => { + console.log("push_callback: push ok!"); + } ) ``` @@ -251,30 +250,30 @@ push(param: PushParameterForStage, callback: AsyncCallback<void>): void ```js pluginComponentManager.push( - { - owner:{ - bundleName:"com.example.provider", - abilityName:"com.example.provider.MainAbility" - }, - target: { - bundleName: "com.example.provider", - abilityName: "com.example.provider.MainAbility", - }, - name: "ets/pages/plugin2.js", - data: { - "js": "ets/pages/plugin.js", - "key_1": 1111, , - }, - extraData: { - "extra_str": "this is push event" - }, - jsonPath: "", + { + owner: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, , + }, + extraData: { + "extra_str": "this is push event" }, - (err, data) => { - console.log("push_callback:err: " ,JSON.stringify(err)); - console.log("push_callback:data: " , JSON.stringify(data)); - console.log("push_callback: push ok!"); - } + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: ", JSON.stringify(err)); + console.log("push_callback:data: ", JSON.stringify(data)); + console.log("push_callback: push ok!"); + } ) ``` @@ -299,24 +298,24 @@ request(param: RequestParameters, callback: AsyncCallback<RequestCallbackPara ```js pluginComponentManager.request( - { - want: { - bundleName: "com.example.provider", - abilityName: "com.example.provider.MainAbility", - }, - name: "plugintemplate", - data: { - "key_1": "plugin component test", - "key_2": 1111111 - }, - jsonPath: "", + { + want: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", }, - (err, data) => { - console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) - console.log("request_callback: data=" + JSON.stringify(data.data)) - console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) - } + name: "plugintemplate", + data: { + "key_1": "plugin component test", + "key_2": 1111111 + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + console.log("request_callback: data=" + JSON.stringify(data.data)) + console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) + } ) ``` @@ -342,25 +341,25 @@ request(param: RequestParameterForStage, callback: AsyncCallback<RequestCallb ```js pluginComponentManager.request( - { - owner:{ - bundleName:"com.example.provider", - abilityName:"com.example.provider.MainAbility" - }, - target: { - bundleName: "com.example.provider", - abilityName: "ets/pages/plugin2.js", - }, - name: "plugintemplate", - data: { - "key_1": " myapplication plugin component test", - }, - jsonPath: "", + { + owner: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", }, - (err, data) => { - console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) - } + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } ) ``` @@ -381,8 +380,8 @@ on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback ): **示例:** ```js - pluginComponentManager.on("push", onPushListener) - pluginComponentManager.on("request", onRequestListener) +pluginComponentManager.on("push", onPushListener) +pluginComponentManager.on("request", onRequestListener) ``` ## external.json文件说明 @@ -396,3 +395,5 @@ external.json文件由开发者创建。external.json中以键值对形式存放 "PluginProviderExample": "ets/pages/PluginProviderExample.js", "plugintemplate2": "ets/pages/plugintemplate2.js" } + +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-router.md b/zh-cn/application-dev/reference/apis/js-apis-router.md index 97d0974a039625a53fa30c3a6d88f8f7ab8dc6f3..52a5633cba72956a34cc350a34ada590ca0aee8f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -320,7 +320,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void> | 错误码ID | 错误信息 | | --------- | ------- | -| 100001 | if UI execution context not found, only throw in standard system. | +| 100001 | if can not get the delegate, only throw in standard system. | | 200002 | if the uri is not exist. | **示例:** @@ -362,7 +362,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback< | 错误码ID | 错误信息 | | --------- | ------- | -| 100001 | if can not get the delegate, only throw in standard system. | +| 100001 | if UI execution context not found, only throw in standard system. | | 200002 | if the uri is not exist. | **示例:** @@ -659,8 +659,8 @@ struct Second { private content: string = "这是第二页" @State text: string = router.getParams()['text'] @State data: object = router.getParams()['data'] - @State secondData : string = '' - + @State secondData: string = '' + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text(`${this.content}`) @@ -668,14 +668,14 @@ struct Second { .fontWeight(FontWeight.Bold) Text(this.text) .fontSize(30) - .onClick(()=>{ + .onClick(() => { this.secondData = (this.data.['array'][1]).toString() }) - .margin({top:20}) + .margin({ top: 20 }) Text(`第一页传来的数值:${this.secondData}`) .fontSize(20) - .margin({top:20}) - .backgroundColor('red') + .margin({ top: 20 }) + .backgroundColor('red') } .width('100%') .height('100%') diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-router.md b/zh-cn/application-dev/reference/apis/js-apis-system-router.md index 96a9e913ce4faf33d435fb8080d8746ad1e26c54..4d22c6d63cb4a3e66c13a22cf2a2fa93fa1220c6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-router.md @@ -341,8 +341,8 @@ export default { | 名称 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | -| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:
- pages/index/index
-pages/detail/detail
2. 特定路径。如果URI为斜杠(/),则显示主页。 | -| params | object | 否 | 表示路由跳转时要同时传递到目标页面的数据。跳转到目标页面后,使用router.getParams()获取传递的参数,此外,在类web范式中,参数也可以在页面中直接使用,如this.keyValue(keyValue为跳转时params参数中的key值),如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | +| uri7+ | string | 是 | 目标页面的uri,可以是以下的两种格式:
1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:
- pages/index/index
-pages/detail/detail
2. 特定路径。如果URI为斜杠(/),则显示主页。 | +| params7+ | object | 否 | 表示路由跳转时要同时传递到目标页面的数据。跳转到目标页面后,使用router.getParams()获取传递的参数,此外,在类web范式中,参数也可以在页面中直接使用,如this.keyValue(keyValue为跳转时params参数中的key值),如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | ## BackRouterOptions @@ -353,8 +353,8 @@ export default { | 名称 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | -| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full | -| params | object | 否 | 跳转时要同时传递到目标页面的数据。
**系统能力:** SystemCapability.ArkUI.ArkUI.Lite | +| uri7+ | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full | +| params7+ | object | 否 | 跳转时要同时传递到目标页面的数据。
**系统能力:** SystemCapability.ArkUI.ArkUI.Lite | ## RouterState