未验证 提交 2ef2cbef 编写于 作者: O openharmony_ci 提交者: Gitee

!7943 【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-window.md.

Merge pull request !7943 from 葛亚芳/N/A
......@@ -302,13 +302,14 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi
```js
var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP);
promise.then((data)=> {
windowClass = data;
console.info('SubWindow created. Data: ' + JSON.stringify(data));
}).catch((err)=>{
window.create("first", window.WindowType.TYPE_APP,(err,data) => {
if(err.code){
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});
return;
}
windowClass = data;
console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
});
```
## window.create<sup>7+</sup>
......@@ -341,7 +342,7 @@ var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP);
promise.then((data)=> {
windowClass = data;
console.info('SubWindow created. Data: ' + JSON.stringify(data));
console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});
......@@ -372,11 +373,11 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi
var windowClass = null;
window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err.code) {
console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
console.info('Window created. Data: ' + JSON.stringify(data));
console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
windowClass.resetSize(500, 1000);
});
```
......@@ -412,7 +413,7 @@ var windowClass = null;
let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> {
windowClass = data;
console.info('Window created. Data:' + JSON.stringify(data));
console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
......@@ -443,7 +444,7 @@ var windowClass = null;
return;
}
windowClass = data;
console.info('window found. Data: ' + JSON.stringify(data));
console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
});
```
......@@ -474,7 +475,7 @@ var windowClass = null;
let promise = window.find("alertWindow");
promise.then((data)=> {
windowClass = data;
console.info('window found. Data: ' + JSON.stringify(data));
console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});
......@@ -868,7 +869,7 @@ windowClass.hide((err, data) => {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return;
}
console.info('window hidden. data: ' + JSON.stringify(data));
console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data));
})
```
......@@ -893,7 +894,7 @@ hide(): Promise&lt;void&gt;
```js
let promise = windowClass.hide();
promise.then((data)=> {
console.info('window hidden. Data: ' + JSON.stringify(data));
console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
......@@ -923,7 +924,7 @@ windowClass.hideWithAnimation((err, data) => {
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
return;
}
console.info('window hidden with animation. data: ' + JSON.stringify(data));
console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data));
})
```
......@@ -948,7 +949,7 @@ hideWithAnimation(): Promise&lt;void&gt;
```js
let promise = windowClass.hideWithAnimation();
promise.then((data)=> {
console.info('window hidden with animation. Data: ' + JSON.stringify(data));
console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
})
......@@ -1135,7 +1136,7 @@ windowClass.moveTo(300, 300, (err, data)=>{
console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return;
}
console.info('Window moved. Data: ' + JSON.stringify(data));
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
});
```
......@@ -1166,7 +1167,7 @@ moveTo(x: number, y: number): Promise&lt;void&gt;
```js
let promise = windowClass.moveTo(300, 300);
promise.then((data)=> {
console.info('Window moved. Data: ' + JSON.stringify(data));
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
......@@ -1196,7 +1197,7 @@ windowClass.resetSize(500, 1000, (err, data) => {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return;
}
console.info('Window size changed. Data: ' + JSON.stringify(data));
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
});
```
......@@ -1226,7 +1227,7 @@ resetSize(width: number, height: number): Promise&lt;void&gt;
```js
let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> {
console.info('Window size changed. Data: ' + JSON.stringify(data));
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});
......@@ -2583,7 +2584,7 @@ setWakeUpScreen(wakeUp: boolean): void;
**示例:**
```ts
```js
var wakeUp = true;
windowClass.setWakeUpScreen(wakeUp);
```
......@@ -3290,9 +3291,8 @@ opacity(opacity: number): void
**示例:**
```ts
```js
windowClass.opacity(0.5);
console.log('set window opacity end');
```
### scale<sup>9+</sup>
......@@ -3313,14 +3313,13 @@ scale(scaleOptions: ScaleOptions): void
**示例:**
```ts
```js
var obj : window.ScaleOptions;
obj.x = 2.0;
obj.y = 1.0;
obj.pivotX = 0.5;
obj.pivotY = 0.5;
windowClass.scale(obj);
console.log('set window scale end');
```
### rotate<sup>9+</sup>
......@@ -3341,7 +3340,7 @@ rotate(rotateOptions: RotateOptions): void
**示例:**
```ts
```js
var obj : window.RotateOptions;
obj.x = 1.0;
obj.y = 1.0;
......@@ -3349,7 +3348,6 @@ obj.z = 45.0;
obj.pivotX = 0.5;
obj.pivotY = 0.5;
windowClass.rotate(obj);
console.log('set window rotate end');
```
### translate<sup>9+</sup>
......@@ -3370,13 +3368,12 @@ translate(translateOptions: TranslateOptions): void
**示例:**
```ts
```js
var obj : window.TranslateOptions;
obj.x = 100.0;
obj.y = 0.0;
obj.z = 0.0;
windowClass.translate(obj);
console.log('set window translate end');
```
### getTransitionController<sup>9+</sup>
......@@ -3397,7 +3394,7 @@ console.log('set window translate end');
**示例:**
```ts
```js
let controller = windowClass.getTransitionController(); // 获取属性转换控制器
controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow
......@@ -3927,7 +3924,7 @@ completeTransition(isCompleted: boolean): void
**示例:**
```ts
```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow
......@@ -3974,7 +3971,7 @@ animationForShown(context: TransitionContext): void
**示例:**
```ts
```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow
......@@ -4015,7 +4012,7 @@ animationForHidden(context: TransitionContext): void
**示例:**
```ts
```js
let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow
......@@ -4039,4 +4036,3 @@ controller.animationForHidden = (context : window.TransitionContext) => {
console.info('complete transition end');
}
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册