diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 4728ae3f1c59c81dfd6fdb8986dca8cff0f8cedc..dc869e902086b8bb309b6f5d229e2f5449842028 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -3063,7 +3063,16 @@ class TestRemoteObject extends rpc.RemoteObject { } let token = new TestRemoteObject('testObject'); +let windowClass = null; +let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context}; try { + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + }); windowClass.bindDialogTarget(token, () => { console.info('Dialog Window Need Destroy.'); }, (err) => { @@ -3136,7 +3145,16 @@ class TestRemoteObject extends rpc.RemoteObject { } let token = new TestRemoteObject('testObject'); +let windowClass = null; +let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context}; try { + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + }); let promise = windowClass.bindDialogTarget(token, () => { console.info('Dialog Window Need Destroy.'); }); @@ -3192,7 +3210,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { onRequest(want, startId) { console.info('onRequest'); + let windowClass = null; + let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context}; try { + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + }); let requestInfo = dialogRequest.getRequestInfo(want) windowClass.bindDialogTarget(requestInfo, () => { console.info('Dialog Window Need Destroy.'); @@ -3204,7 +3231,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { console.info('Succeeded in binding dialog target.'); }); } catch(err) { - console.error('getRequestInfo err = ' + JSON.stringify(err)) + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)) } } @@ -3269,7 +3296,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { onRequest(want, startId) { console.info('onRequest'); + let windowClass = null; + let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context}; try { + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + }); let requestInfo = dialogRequest.getRequestInfo(want) let promise = windowClass.bindDialogTarget(requestInfo, () => { console.info('Dialog Window Need Destroy.'); @@ -3280,7 +3316,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); }); } catch(err) { - console.error('getRequestInfo err = ' + JSON.stringify(err)) + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)) } }