鸿蒙开发接口图形图像:【@ohos.window (窗口)】

2024-05-30 18:04

本文主要是介绍鸿蒙开发接口图形图像:【@ohos.window (窗口)】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

窗口

窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。

该模块提供以下窗口相关的常用功能:

  • [Window]:当前窗口实例,窗口管理器管理的基本单元。
  • [WindowStage]:窗口管理器。管理各个基本窗口单元。
说明:
开发前请熟悉鸿蒙开发指导文档: gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md点击或者复制转到。
本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

导入模块

import window from '@ohos.window';

WindowType7+

窗口类型枚举。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称说明
TYPE_APP0表示应用子窗口。此接口仅可在FA模型下使用。
TYPE_SYSTEM_ALERT1表示系统告警窗口。此接口仅可在Stage模型下使用。

AvoidAreaType7+

窗口内容需要规避区域的类型枚举。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称说明
TYPE_SYSTEM0表示系统默认区域。
TYPE_CUTOUT1表示刘海屏区域。

WindowMode7+

窗口模式枚举。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称说明
UNDEFINED1表示APP未定义窗口模式。
FULLSCREEN2表示APP全屏模式。
PRIMARY3表示APP分屏多窗口主要模式。
SECONDARY4表示APP分屏多窗口次要模式。
FLOATING5表示APP自由悬浮形式窗口模式。

WindowLayoutMode9+

窗口布局模式枚举。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称说明
WINDOW_LAYOUT_MODE_CASCADE0表示使用层叠布局模式。
WINDOW_LAYOUT_MODE_TILE1表示使用平铺布局模式。

SystemBarProperties

状态栏、导航栏的属性。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
statusBarColorstring状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00#FF00FF00
isStatusBarLightIcon7+boolean状态栏图标是否为高亮状态。
statusBarContentColor8+string状态栏文字颜色。
navigationBarColorstring导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00#FF00FF00
isNavigationBarLightIcon7+boolean导航栏图标是否为高亮状态。
navigationBarContentColor8+string导航栏文字颜色。

SystemBarRegionTint8+

单个导航栏或状态栏回调信息。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
type[WindowType]当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。
isEnableboolean当前系统栏是否显示。
region[Rect]当前系统栏的位置及大小。
backgroundColorstring系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00#FF00FF00
contentColorstring系统栏文字颜色。

SystemBarTintState8+

当前系统栏回调信息集合。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
displayIdnumber当前物理屏幕id。
regionTintArray<[SystemBarRegionTint]>当前已改变的所有系统栏信息。

Rect7+

窗口矩形区域。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
leftnumber矩形区域的左边界。
topnumber矩形区域的上边界。
widthnumber矩形区域的宽度。
heightnumber矩形区域的高度。

AvoidArea7+

窗口内容规避区域。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
leftRect[Rect]屏幕左侧的矩形区。
topRect[Rect]屏幕顶部的矩形区。
rightRect[Rect]屏幕右侧的矩形区。
bottomRect[Rect]屏幕底部的矩形区。

Size7+

窗口大小。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
widthnumber窗口宽度。
heightnumber窗口高度。

WindowProperties

窗口属性。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称参数类型可读可写说明
windowRect7+[Rect]窗口尺寸。
type7+[WindowType]窗口类型。
isFullScreenboolean是否全屏,默认为false。
isLayoutFullScreen7+boolean窗口是否为沉浸式,默认为false。
focusable7+boolean窗口是否可聚焦,默认为true。
touchable7+boolean窗口是否可触摸,默认为true。
brightnessnumber屏幕亮度, 取值范围为0~1,1表示最大亮度值。
dimBehindValue(deprecated)number靠后窗口的暗度值,取值范围为0~1,1表示最暗。 - 说明:  从API version 9开始废弃。 - 从 API version 7开始支持
isKeepScreenOnboolean屏幕是否常亮,默认为false。
isPrivacyMode7+boolean隐私模式,默认为false。
isRoundCorner7+boolean窗口是否为圆角。默认为false。
isTransparent7+boolean窗口是否透明。默认为false。

ColorSpace8+

色域模式。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称默认值说明
DEFAULT0默认色域模式。
WIDE_GAMUT1广色域模式。

window.create7+

create(id: string, type: WindowType, callback: AsyncCallback<Window>): void

创建子窗口,使用callback异步回调。

此接口仅可在FA模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
idstring窗口id。
type[WindowType]窗口类型。
callbackAsyncCallback<[Window]>回调函数。返回当前创建的子窗口对象。

示例:

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)=>{console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));});

window.create7+

create(id: string, type: WindowType): Promise<Window>

创建子窗口,使用Promise异步回调。

此接口仅可在FA模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
idstring窗口id。
type[WindowType]窗口类型。

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前创建的子窗口对象。

示例:

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)=>{console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
});

window.create8+

create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void

创建子窗口,使用callback异步回调,其中Context详见[Context]。

从API version 9开始,当Context为[ServiceExtensionContext]时,创建系统窗口,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
ctxContext当前应用上下文信息。 API version 8的Context定义见[Context]。 API version 9的Context定义见[Context]。
idstring窗口id。
type[WindowType]窗口类型。
callbackAsyncCallback<[Window]>回调函数。返回当前创建的子窗口对象。

示例:

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));return;}windowClass = data;console.info('Window created. Data: ' + JSON.stringify(data));windowClass.resetSize(500, 1000);
});

window.create8+

create(ctx: Context, id: string, type: WindowType): Promise<Window>

创建子窗口,使用Promise异步回调,其中Context详见[Context]

从API version 9开始,当Context为[ServiceExtensionContext]时,创建系统窗口,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
ctxContext当前应用上下文信息。 API version 8的Context定义见[Context] API version 9的Context定义见[Context]。
idstring窗口id。
type[WindowType]窗口类型。

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前创建的子窗口对象。

示例:

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));
}).catch((err)=>{console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});

window.find7+

find(id: string, callback: AsyncCallback<Window>): void

查找id所对应的窗口,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
idstring窗口id。
callbackAsyncCallback<[Window]>回调函数。返回当前查找到的窗口对象。

示例:

var windowClass = null;window.find("alertWindow", (err, data) => {if (err.code) {console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));return;}windowClass = data;console.info('window found. Data: ' + JSON.stringify(data));
});

window.find7+

find(id: string): Promise<Window>

查找id所对应的窗口,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
idstring窗口id。

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前查找的窗口对象。

示例:

var windowClass = null;
let promise = window.find("alertWindow");
promise.then((data)=> {windowClass = data;console.info('window found. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
});

window.getTopWindow

getTopWindow(callback: AsyncCallback<Window>): void

获取当前应用内最后显示的窗口,使用callback异步回调。

此接口仅可在FA模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<[Window]>回调函数。返回当前应用内最后显示的窗口对象。

示例:

var windowClass = null;
window.getTopWindow((err, data) => {if (err.code) {console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));return;}windowClass = data;console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});

window.getTopWindow

getTopWindow(): Promise<Window>

获取当前应用内最后显示的窗口,使用Promise异步回调。

此接口仅可在FA模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前应用内最后显示的窗口对象。

示例:

var windowClass = null;
let promise = window.getTopWindow();
promise.then((data)=> {windowClass = data;console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})

window.getTopWindow8+

getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void

获取当前应用内最后显示的窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
ctxContext当前应用上下文信息。 API version 8的Context定义见[Context]。 API version 9的Context定义见[Context]。
callbackAsyncCallback<[Window]>回调函数。返回当前应用内最后显示的窗口对象。

示例:

var windowClass = null;
window.getTopWindow(this.context, (err, data) => {if (err.code) {console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));return;}windowClass = data;console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});

window.getTopWindow8+

getTopWindow(ctx: Context): Promise<Window>

获取当前应用内最后显示的窗口,使用Promise异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
ctxContext当前应用上下文信息。 API version 8的Context定义见[Context]。 API version 9的Context定义见[Context]。

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前应用内最后显示的窗口对象。

示例:

var windowClass = null;
let promise = window.getTopWindow(this.context);
promise.then((data)=> {windowClass = data;console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})

window.minimizeAll9+

minimizeAll(id: number, callback: AsyncCallback<void>): void

最小化某显示设备下的所有窗口。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
idnumber显示设备[Display]的ID号
callbackAsyncCallback<void>回调信息。

示例:

import display from '@ohos.display'
import window from '@ohos.window'var displayClass = null;
display.getDefaultDisplay((err, data) => {if(err.code) {return;}displayClass = data;window.minimizeAll(displayClass.id, (err, data) => {if(err.code) {console.error('Failed to minimize all window. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in minimizing all window.');});
});

window.minimizeAll9+

minimizeAll(id: number): Promise<void>

最小化某显示设备下的所有窗口。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
idnumber显示设备[Display]的ID号

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

import display from '@ohos.display'
import window from '@ohos.window'var displayClass = null;
display.getDefaultDisplay((err, data) => {if(err.code) {return;}displayClass = data;let promise = window.minimizeAll(displayClass.id);promise.then((data)=> {console.info('Succeeded in minimizing all window.');}).catch((err)=>{console.error('Failed to minimize all window. Cause: ' + JSON.stringify(err));})
});

window.toggleShownStateForAllAppWindows9+

toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void

多窗口快速切换时隐藏或者恢复应用窗口。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<void>回调信息。

示例:

window.toggleShownStateForAllAppWindows((err, data) => {if (err.code) {console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in toggling shown state for all app windows.');
})

window.toggleShownStateForAllAppWindows9+

toggleShownStateForAllAppWindows(): Promise<void>

多窗口快速切换时隐藏或者恢复应用窗口。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = window.toggleShownStateForAllAppWindows();
promise.then((data)=> {console.info('Succeeded in toggling shown state for all app windows. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
})

window.setWindowLayoutMode9+

setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>): void

设置窗口布局模式。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
mode[WindowLayoutMode]设置的窗口布局模式
callbackAsyncCallback<void>回调信息。

示例:

window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => {console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
});

window.setWindowLayoutMode9+

setWindowLayoutMode(mode: WindowLayoutMode): Promise<void>

设置窗口布局模式。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
mode[WindowLayoutMode]设置的窗口布局模式

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
promise.then((data)=> {console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
})

on('systemBarTintChange')8+

on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void

开启状态栏、导航栏属性变化的监听。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。
callbackCallback<[SystemBarTintState]>回调函数。返回当前的状态栏、导航栏信息集合。

示例:

window.on('systemBarTintChange', (data) => {console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
});

off('systemBarTintChange')8+

off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void

关闭状态栏、导航栏属性变化的监听。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。
callbackCallback<[SystemBarTintState]>回调函数。返回当前的状态栏、导航栏信息集合。

示例:

window.off('systemBarTintChange');

Window

当前窗口实例,窗口管理器管理的基本单元。

下列API示例中都需先使用[getTopWindow()]、[create()]、[find()]中的任一方法获取到Window实例,再通过此实例调用对应方法。

hide7+

hide (callback: AsyncCallback<void>): void

隐藏当前窗口,使用callback异步回调。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<void>回调函数。

示例:

windowClass.hide((err, data) => {if (err.code) {console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));return;}console.info('window hidden. data: ' + JSON.stringify(data));
})

hide7+

hide(): Promise<void>

隐藏当前窗口,使用Promise异步回调。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.hide();
promise.then((data)=> {console.info('window hidden. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})

show7+

show(callback: AsyncCallback<void>): void

显示当前窗口,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<void>回调函数。

示例:

windowClass.show((err, data) => {if (err.code) {console.error('Failed to show the window. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
})

show7+

show(): Promise<void>

显示当前窗口,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.show();
promise.then((data)=> {console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
})

destroy7+

destroy(callback: AsyncCallback<void>): void

销毁当前窗口,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<void>回调函数。

示例:

windowClass.destroy((err, data) => {if (err.code) {console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
})

destroy7+

destroy(): Promise<void>

销毁当前窗口,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.destroy();
promise.then((data)=> {console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})

moveTo7+

moveTo(x: number, y: number, callback: AsyncCallback<void>): void

移动窗口位置,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
xnumber窗口在x轴方向移动的值,值为正表示右移,单位为px。
ynumber窗口在y轴方向移动的值,值为正表示下移,单位为px。
callbackAsyncCallback<void>回调函数。

示例:

windowClass.moveTo(300, 300, (err, data)=>{if (err.code) {console.error('Failed to move the window. Cause:' + JSON.stringify(err));return;}console.info('Window moved. Data: ' + JSON.stringify(data));});

moveTo7+

moveTo(x: number, y: number): Promise<void>

移动窗口位置,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
xnumber窗口在x轴方向移动的值,值为正表示右移,单位为px。
ynumber窗口在y轴方向移动的值,值为正表示下移,单位为px。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.moveTo(300, 300);
promise.then((data)=> {console.info('Window moved. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})

resetSize7+

resetSize(width: number, height: number, callback: AsyncCallback<void>): void

改变当前窗口大小,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
widthnumber目标窗口的宽度,单位为px。
heightnumber目标窗口的高度,单位为px。
callbackAsyncCallback<void>回调函数。

示例:

windowClass.resetSize(500, 1000, (err, data) => {if (err.code) {console.error('Failed to change the window size. Cause:' + JSON.stringify(err));return;}console.info('Window size changed. Data: ' + JSON.stringify(data));
});

resetSize7+

resetSize(width: number, height: number): Promise<void>

改变当前窗口大小,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
widthnumber目标窗口的宽度,单位为px。
heightnumber目标窗口的高度,单位为px。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> {console.info('Window size changed. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});

setWindowType7+

setWindowType(type: WindowType, callback: AsyncCallback<void>): void

设置窗口类型,使用callback异步回调。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
type[WindowType]窗口类型。
callbackAsyncCallback<void>回调函数。

示例:

var type = window.WindowType.TYPE_APP;
windowClass.setWindowType(type, (err, data) => {if (err.code) {console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
});

setWindowType7+

setWindowType(type: WindowType): Promise<void>

设置窗口类型,使用Promise异步回调。

此接口为系统接口,三方应用不支持调用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
type[WindowType]窗口类型。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var type = window.WindowType.TYPE_APP;
let promise = windowClass.setWindowType(type);
promise.then((data)=> {console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
});

getProperties

getProperties(callback: AsyncCallback<WindowProperties>): void

获取当前窗口的属性,使用callback异步回调,返回WindowProperties。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<[WindowProperties]>回调函数。返回当前窗口属性。

示例:

windowClass.getProperties((err, data) => {if (err.code) {console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
});

getProperties

getProperties(): Promise<WindowProperties>

获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<[WindowProperties]>Promise对象。返回当前窗口属性。

示例:

let promise = windowClass.getProperties();
promise.then((data)=> {console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
});

getAvoidArea7+

getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): void

获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
type[AvoidAreaType]表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。
callbackAsyncCallback<[AvoidArea]>回调函数。返回窗口内容规避区域。

示例:

var type = window.AvoidAreaType.TYPE_SYSTEM;
windowClass.getAvoidArea(type, (err, data) => {if (err.code) {console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
});

getAvoidArea7+

getAvoidArea(type: AvoidAreaType): Promise<AvoidArea>

获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
type[AvoidAreaType]表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。

返回值:

类型说明
Promise<[AvoidArea]>Promise对象。返回窗口内容规避区域。

示例:

let promise = windowClass.getAvoidArea();
promise.then((data)=> {console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
});

setFullScreen

setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void

设置是否为全屏状态,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isFullScreenboolean是否设为全屏状态,且全屏状态隐藏状态栏导航栏。
callbackAsyncCallback<void>回调函数。

示例:

var isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err, data) => {if (err.code) {console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
});

setFullScreen

setFullScreen(isFullScreen: boolean): Promise<void>

设置是否为全屏状态,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isFullScreenboolean是否设为全屏状态,且全屏状态隐藏状态栏导航栏。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var isFullScreen = true;
let promise = windowClass.setFullScreen(isFullScreen);
promise.then((data)=> {console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
});

setLayoutFullScreen7+

setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void

设置窗口的布局是否为全屏显示状态,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isLayoutFullScreenboolean窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。
callbackAsyncCallback<void>回调函数。

示例:

var isLayoutFullScreen= true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {if (err.code) {console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
});

setLayoutFullScreen7+

setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>

设置窗口的布局是否为全屏显示状态,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isLayoutFullScreenboolean窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var isLayoutFullScreen = true;
let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
promise.then((data)=> {console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
});

setSystemBarEnable7+

setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void

设置导航栏、状态栏的可见模式,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
namesArray设置状态栏和导航栏是否显示。 例如,需全部显示,该参数设置为["status", "navigation"];不设置,则默认不显示。
callbackAsyncCallback<void>回调函数。

示例:

var names = ["status", "navigation"];
windowClass.setSystemBarEnable(names, (err, data) => {if (err.code) {console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
});

setSystemBarEnable7+

setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>

设置导航栏、状态栏的可见模式,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
namesArray设置状态栏和导航栏是否显示。 例如,需全部显示,该参数设置为["status", "navigation"];不设置,则默认不显示。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var names = ["status", "navigation"];
let promise = windowClass.setSystemBarEnable(names);
promise.then((data)=> {console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
});

setSystemBarProperties

setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void

设置窗口内导航栏、状态栏的属性,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
SystemBarProperties[SystemBarProperties]导航栏、状态栏的属性。
callbackAsyncCallback<void>回调函数。

示例:

var SystemBarProperties={statusBarColor: '#ff00ff',navigationBarColor: '#00ff00',//以下两个属性从API Version7开始支持isStatusBarLightIcon: true,isNavigationBarLightIcon:false,//以下两个属性从API Version8开始支持statusBarContentColor:'#ffffff',navigationBarContentColor:'#00ffff'
};
windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {if (err.code) {console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
});

setSystemBarProperties

setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void>

设置窗口内导航栏、状态栏的属性,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
SystemBarProperties[SystemBarProperties]导航栏、状态栏的属性。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var SystemBarProperties={statusBarColor: '#ff00ff',navigationBarColor: '#00ff00',//以下两个属性从API Version7开始支持isStatusBarLightIcon: true,isNavigationBarLightIcon:false,//以下两个属性从API Version8开始支持statusBarContentColor:'#ffffff',navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then((data)=> {console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
});

loadContent7+

loadContent(path: string, callback: AsyncCallback<void>): void

为当前窗口加载具体页面内容,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。
callbackAsyncCallback<void>回调函数。

示例:

windowClass.loadContent("pages/page2/page2", (err, data) => {if (err.code) {console.error('Failed to load the content. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});

loadContent7+

loadContent(path: string): Promise<void>

为当前窗口加载具体页面内容,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.loadContent("pages/page2/page2");
promise.then((data)=> {console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
});

loadContent9+

loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void

为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。
storage[LocalStorage]存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。
callbackAsyncCallback<void>回调函数。

示例:

class myAbility extends Ability {storage : LocalStorage  onWindowStageCreate(windowStage) {this.storage = new LocalStorage();this.storage.setOrCreate("storageSimpleProp",121);console.log('onWindowStageCreate');windowStage.loadContent("pages/page2",this.storage,(err, data) => {if (err.code) {console.error('Failed to load the content. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));});}
}

loadContent9+

loadContent(path: string, storage: LocalStorage): Promise<void>

为当前窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。
storage[LocalStorage]存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

class myAbility extends Ability {storage : LocalStorage onWindowStageCreate(windowStage) {this.storage = new LocalStorage();this.storage.setOrCreate("storageSimpleProp",121);console.log('onWindowStageCreate');var windowClass = null;let promise = windowStage.loadContent("pages/page2",this.storage);promise.then((data)=> {windowClass = data;console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));}).catch((err)=>{console.error('Failed to load the content. Cause:' + JSON.stringify(err));})}
}

isShowing7+

isShowing(callback: AsyncCallback<boolean>): void

判断当前窗口是否已显示,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<boolean>回调函数。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。

示例:

windowClass.isShowing((err, data) => {if (err.code) {console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
});

isShowing7+

isShowing(): Promise<boolean>

判断当前窗口是否已显示,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<boolean>Promise对象。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。

示例:

let promise = windowClass.isShowing();
promise.then((data)=> {console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
});

on('windowSizeChange')7+

on(type: 'windowSizeChange', callback: Callback<Size>): void

开启窗口尺寸变化的监听。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。
callbackCallback<[Size]>回调函数。返回当前的窗口尺寸。

示例:

windowClass.on('windowSizeChange', (data) => {console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
});

off('windowSizeChange')7+

off(type: 'windowSizeChange', callback?: Callback<Size >): void

关闭窗口尺寸变化的监听。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。
callbackCallback<[Size]>回调函数。返回当前的窗口尺寸。

示例:

windowClass.off('windowSizeChange');

on('systemAvoidAreaChange')7+

on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void

开启系统窗口规避区变化的监听。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。
callbackCallback<[AvoidArea]>回调函数。返回当前的窗口规避区。

示例:

windowClass.on('systemAvoidAreaChange', (data) => {console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
});

off('systemAvoidAreaChange')7+

off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void

关闭系统窗口规避区变化的监听。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。
callbackCallback<[AvoidArea]>回调函数。返回当前的窗口规避区。

示例:

windowClass.off('systemAvoidAreaChange');

on('keyboardHeightChange')7+

on(type: 'keyboardHeightChange', callback: Callback<number>): void

开启键盘高度变化的监听。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。
callbackCallback<number>回调函数。返回当前的键盘高度。

示例:

windowClass.on('keyboardHeightChange', (data) => {console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
});

off('keyboardHeightChange')7+

off(type: 'keyboardHeightChange', callback?: Callback<number>): void

关闭键盘高度变化的监听。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。
callbackCallback<number>回调函数。返回当前的键盘高度。

示例:

windowClass.off('keyboardHeightChange');

isSupportWideGamut8+

isSupportWideGamut(callback: AsyncCallback<boolean>): void

判断当前窗口是否支持广色域模式,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<boolean>回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。

示例:

windowClass.isSupportWideGamut((err, data) => {if (err.code) {console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
})

isSupportWideGamut8+

isSupportWideGamut(): Promise<boolean>

判断当前窗口是否支持广色域模式,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<boolean>Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。

示例:

let promise = windowClass.isSupportWideGamut();
promise.then((data)=> {console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
});

setColorSpace8+

setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void

设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
colorSpace[ColorSpace]设置色域模式
callbackAsyncCallback<void>回调函数。

示例:

windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {if (err.code) {console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
})

setColorSpace8+

setColorSpace(colorSpace:ColorSpace): Promise<void>

设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
colorSpace[ColorSpace]设置色域模式。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
promise.then((data)=> {console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
});

getColorSpace8+

getColorSpace(callback: AsyncCallback<ColorSpace>): void

获取当前窗口色域模式,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<[ColorSpace]>回调函数。当获取成功,err为undefined,data为当前色域模式。

示例:

windowClass.getColorSpace((err, data) => {if (err.code) {console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
})

getColorSpace8+

getColorSpace(): Promise<ColorSpace>

获取当前窗口色域模式,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<[ColorSpace]>Promise对象。返回当前色域模式。

示例:

let promise = windowClass.getColorSpace();
promise.then((data)=> {console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
});

setBackgroundColor

setBackgroundColor(color: string, callback: AsyncCallback<void>): void

设置窗口的背景色,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
colorstring需要设置的背景色,为十六进制颜色,不区分大小写,例如#00FF00#FF00FF00
callbackAsyncCallback<void>回调函数。

示例:

var color = '#00ff33';
windowClass.setBackgroundColor(color, (err, data) => {if (err.code) {console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
});

setBackgroundColor

setBackgroundColor(color: string): Promise<void>

设置窗口的背景色,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
colorstring需要设置的背景色,为十六进制颜色,不区分大小写,例如"#00FF00"或"#FF00FF00"。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var color = '#00ff33';
let promise = windowClass.setBackgroundColor(color);
promise.then((data)=> {console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
});

setBrightness

setBrightness(brightness: number, callback: AsyncCallback<void>): void

设置屏幕亮度值,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
brightnessnumber屏幕亮度值,值为0-1之间。1表示最亮。
callbackAsyncCallback<void>回调函数。

示例:

var brightness = 1;
windowClass.setBrightness(brightness, (err, data) => {if (err.code) {console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
});

setBrightness

setBrightness(brightness: number): Promise<void>

设置屏幕亮度值,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
brightnessnumber屏幕亮度值,值为0-1之间。1表示最亮。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var brightness = 1;
let promise = windowClass.setBrightness(brightness);
promise.then((data)=> {console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
});

setDimBehind(deprecated)

setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void

窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。

说明:  从API version 9开始废弃。

从 API version 7开始支持。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
dimBehindValuenumber表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。
callbackAsyncCallback<void>回调函数。

示例:

windowClass.setDimBehind(0.5, (err, data) => {if (err.code) {console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
});

setDimBehind(deprecated)

setDimBehind(dimBehindValue: number): Promise<void>

窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。

说明:  从API version 9开始废弃。

从 API version 7开始支持。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
dimBehindValuenumber表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.setDimBehind(0.5);
promise.then((data)=> {console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
});

setFocusable7+

setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void

设置点击时是否支持切换焦点窗口,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isFocusableboolean点击时是否支持切换焦点窗口。
callbackAsyncCallback<void>回调函数。

示例:

var isFocusable= true;
windowClass.setFocusable(isFocusable, (err, data) => {if (err.code) {console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
});

setFocusable7+

setFocusable(isFocusable: boolean): Promise<void>

设置点击时是否支持切换焦点窗口,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isFocusableboolean点击时是否支持切换焦点窗口。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var isFocusable= true;
let promise = windowClass.setFocusable(isFocusable);
promise.then((data)=> {console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
});

setKeepScreenOn

setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void

设置屏幕是否为常亮状态,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isKeepScreenOnboolean设置屏幕是否为常亮状态。
callbackAsyncCallback<void>回调函数。

示例:

var isKeepScreenOn = true;
windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {if (err.code) {console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
});

setKeepScreenOn

setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>

设置屏幕是否为常亮状态,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isKeepScreenOnboolean设置屏幕是否为常亮状态。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var isKeepScreenOn = true;
let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
promise.then((data) => {console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.info('Failed to set the screen to be always on. Cause:  ' + JSON.stringify(err)); 
});

setOutsideTouchable(deprecated)

setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void

设置是否允许可点击子窗口之外的区域,使用callback异步回调。

说明:  从API version 9开始废弃。

从 API version 7开始支持。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
touchableboolean设置是否可点击。
callbackAsyncCallback<void>回调函数。

示例:

windowClass.setOutsideTouchable(true, (err, data) => {if (err.code) {console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));return;}console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
})

setOutsideTouchable(deprecated)

setOutsideTouchable(touchable: boolean): Promise<void>

设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。

说明:  从API version 9开始废弃。

从 API version 7开始支持。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
touchableboolean设置是否可点击。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

let promise = windowClass.setOutsideTouchable(true);
promise.then((data)=> {console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
});

setPrivacyMode7+

setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void

设置窗口是否为隐私模式,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isPrivacyModeboolean窗口是否为隐私模式。
callbackAsyncCallback<void>回调函数。

示例:

var isPrivacyMode = true;
windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {if (err.code) {console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));});

setPrivacyMode7+

setPrivacyMode(isPrivacyMode: boolean): Promise<void>

设置窗口是否为隐私模式,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isPrivacyModeboolean窗口是否为隐私模式。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var isPrivacyMode = true;
let promise = windowClass.setPrivacyMode(isPrivacyMode);
promise.then((data)=> {console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
});

setTouchable7+

setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void

设置窗口是否为可触状态,使用callback异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isTouchableboolean窗口是否为可触状态。
callbackAsyncCallback<void>回调函数。

示例:

var isTouchable = true;
windowClass.setTouchable(isTouchable, (err, data) => {if (err.code) {console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));});

setTouchable7+

setTouchable(isTouchable: boolean): Promise<void>

设置窗口是否为可触状态,使用Promise异步回调。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
isTouchableboolean窗口是否为可触状态。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

var isTouchable = true;
let promise = windowClass.setTouchable(isTouchable);
promise.then((data)=> {console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
});

WindowStageEventType9+

WindowStage生命周期。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

名称默认值说明
FOREGROUND1切到前台。
ACTIVE2获焦状态。
INACTIVE3失焦状态。
BACKGROUND4切到后台。

WindowStage9+

窗口管理器。管理各个基本窗口单元,即[Window]实例。

下列API示例中都需在[onWindowStageCreate()]函数中使用WindowStage的实例调用对应方法。

getMainWindow9+

getMainWindow(callback: AsyncCallback<Window>): void

获取该WindowStage实例下的主窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<[Window]>回调函数。返回当前WindowStage下的主窗口对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');var windowClass = null;windowStage.getMainWindow((err, data) => {if (err.code) {console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));return;}windowClass = data;console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));});}
}

getMainWindow9+

getMainWindow(): Promise<Window>

获取该WindowStage实例下的主窗口,使用Promise异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前WindowStage下的主窗口对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');var windowClass = null;let promise = windowStage.getMainWindow();promise.then((data)=> {windowClass = data;console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));}).catch((err)=>{console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));});}
}

createSubWindow9+

createSubWindow(name: string, callback: AsyncCallback<Window>): void

创建该WindowStage实例下的子窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
nameString子窗口的名字。
callbackAsyncCallback<[Window]>回调函数。返回当前WindowStage下的子窗口对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');var windowClass = null;windowStage.createSubWindow("mySubWindow", (err, data) => {if (err.code) {console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));return;}windowClass = data;console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));windowClass.resetSize(500, 1000);});}
}

createSubWindow9+

createSubWindow(name: string): Promise<Window>

创建该WindowStage实例下的子窗口,使用Promise异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
nameString子窗口的名字。

返回值:

类型说明
Promise<[Window]>Promise对象。返回当前WindowStage下的子窗口对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');var windowClass = null;let promise = windowStage.createSubWindow("mySubWindow");promise.then((data)=> {windowClass = data;console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));}).catch((err)=>{console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));})}
}

getSubWindow9+

getSubWindow(callback: AsyncCallback<Array<Window>>): void

获取该WindowStage实例下的所有子窗口,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
callbackAsyncCallback<Array<[Window]>>回调函数。返回当前WindowStage下的所有子窗口对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');var windowClass = null;windowStage.getSubWindow((err, data) => {if (err.code) {console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));return;}windowClass = data;console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));});}
}

getSubWindow9+

getSubWindow(): Promise<Array<Window>>

获取该WindowStage实例下的所有子窗口,使用Promise异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

返回值:

类型说明
Promise<Array<[Window]>>Promise对象。返回当前WindowStage下的所有子窗口对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');var windowClass = null;let promise = windowStage.getSubWindow();promise.then((data)=> {windowClass = data;console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));}).catch((err)=>{console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));})}
}

loadContent9+

loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void

为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。
storage[LocalStorage]存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。
callbackAsyncCallback<void>回调函数。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {storage : LocalStorage  onWindowStageCreate(windowStage) {this.storage = new LocalStorage();this.storage.setOrCreate("storageSimpleProp",121);console.log('onWindowStageCreate');windowStage.loadContent("pages/page2",this.storage,(err, data) => {if (err.code) {console.error('Failed to load the content. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));});}
}

loadContent9+

loadContent(path: string, storage?: LocalStorage): Promise<void>

为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。
storage[LocalStorage]存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。

返回值:

类型说明
Promise<void>无返回结果的Promise对象。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {storage : LocalStorage onWindowStageCreate(windowStage) {this.storage = new LocalStorage();this.storage.setOrCreate("storageSimpleProp",121);console.log('onWindowStageCreate');var windowClass = null;let promise = windowStage.loadContent("pages/page2",this.storage);promise.then((data)=> {windowClass = data;console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));}).catch((err)=>{console.error('Failed to load the content. Cause:' + JSON.stringify(err));})}
}

loadContent9+

loadContent(path: string, callback: AsyncCallback<void>): void

为当前WindowStage的主窗口加载具体页面内容,使用callback异步回调。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
pathstring设置加载页面的路径。
callbackAsyncCallback<void>回调函数。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');windowStage.loadContent("pages/page2", (err, data) => {if (err.code) {console.error('Failed to load the content. Cause:' + JSON.stringify(err));return;}console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));});}
}

on('windowStageEvent')9+

on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>): void

开启WindowStage生命周期变化的监听。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明
typestring监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。
callbackCallback<[WindowStageEventType]>回调函数。返回当前的WindowStage生命周期状态。

示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');windowStage.on('windowStageEvent', (data) => {console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));});}
}

off('windowStageEvent')9+

off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType>): void

关闭WindowStage生命周期变化的监听。

此接口仅可在Stage模型下使用。

系统能力:  SystemCapability.WindowManager.WindowManager.Core

参数:

参数名类型必填说明 HarmonyOS与OpenHarmony鸿蒙文档籽料:mau123789是v直接拿
typestring监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。
callbackCallback<[WindowStageEventType]>回调函数。返回当前的WindowStage生命周期状态。

鸿蒙文档.png


示例:

import Ability from '@ohos.application.Ability';
class myAbility extends Ability {onWindowStageCreate(windowStage) {console.log('onWindowStageCreate');windowStage.off('windowStageEvent');}
}

到这里我们就基本上学完了这个知识点,当然如果说要真正参与到鸿蒙的开发当中,要学的还有很多。大家可以看看下面这个鸿蒙入门到实战的学习技术路线图:

 而随着鸿蒙的火热,现阶段已有许多Android、前端等开发者看中其未来趋势;想从网上查阅学习,但搜索到的鸿蒙资料都是七零八碎的,对此为了避免大家在学习过程中浪费过多时间,特地根据鸿蒙官方发布文档结合华为内部人员的分享,经过反复修改整理得出:

整套鸿蒙(HarmonyOS NEXT)学习手册(共计1236页)与鸿蒙(HarmonyOS NEXT开发入门&实战教学视频(200集+)发放给大家。

内容包含了:(ArkTS、ArkUI、Stage模型、多端部署、分布式应用开发、音频、视频、WebGL、OpenHarmony多媒体技术、Napi组件、OpenHarmony内核、鸿蒙南向开发、鸿蒙项目实战)等技术知识点。帮助大家在学习鸿蒙路上少走弯路!下面点击↓↓↓拿

废话不多说,接下来好好看下这份资料。

《鸿蒙 (HarmonyOS NEXT)开发基础到实战手册》

OpenHarmony北向、南向开发环境搭建

鸿蒙开发基础》

  1. ArkTS语言

  2. 安装DevEco Studio

  3. 运用你的第一个ArkTS应用

  4. ArkUI声明式UI开发

  5. .……

《鸿蒙开发进阶》

  1. Stage模型入门

  2. 网络管理

  3. 数据管理

  4. 电话服务

  5. 分布式应用开发

  6. 通知与窗口管理

  7. 多媒体技术

  8. 安全技能

  9. 任务管理

  10. WebGL

  11. 国际化开发

  12. 应用测试

  13. DFX面向未来设计

  14. 鸿蒙系统移植和裁剪定制

  15. ……

《鸿蒙开发实战》

  1. ArkTS实践

  2. UIAbility应用

  3. 网络案例

  4. ……

《鸿蒙 (HarmonyOS NEXT)开发入门&实战教学视频》  

↑↑↑点击即可

这篇关于鸿蒙开发接口图形图像:【@ohos.window (窗口)】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1016662

相关文章

Eclipse+ADT与Android Studio开发的区别

下文的EA指Eclipse+ADT,AS就是指Android Studio。 就编写界面布局来说AS可以边开发边预览(所见即所得,以及多个屏幕预览),这个优势比较大。AS运行时占的内存比EA的要小。AS创建项目时要创建gradle项目框架,so,创建项目时AS比较慢。android studio基于gradle构建项目,你无法同时集中管理和维护多个项目的源码,而eclipse ADT可以同时打开

Python应用开发——30天学习Streamlit Python包进行APP的构建(9)

st.area_chart 显示区域图。 这是围绕 st.altair_chart 的语法糖。主要区别在于该命令使用数据自身的列和指数来计算图表的 Altair 规格。因此,在许多 "只需绘制此图 "的情况下,该命令更易于使用,但可定制性较差。 如果 st.area_chart 无法正确猜测数据规格,请尝试使用 st.altair_chart 指定所需的图表。 Function signa

vue3项目将所有访问后端springboot的接口统一管理带跨域

vue3项目将所有访问后端springboot的接口统一管理带跨域 一、前言1.安装Axios2.创建Axios实例3.创建API服务文件4.在组件中使用API服务 二、跨域三、总结 一、前言 在Vue 3项目中,统一管理所有访问后端Spring Boot接口的最佳实践是创建一个专门的API服务层。这可以让你的代码更加模块化、可维护和集中管理。你可以使用Axios库作为HTT

WDF驱动开发-WDF总线枚举(一)

支持在总线驱动程序中进行 PnP 和电源管理 某些设备永久插入系统,而其他设备可以在系统运行时插入和拔出电源。 总线驱动 必须识别并报告连接到其总线的设备,并且他们必须发现并报告系统中设备的到达和离开情况。 总线驱动程序标识和报告的设备称为总线的 子设备。 标识和报告子设备的过程称为 总线枚举。 在总线枚举期间,总线驱动程序会为其子 设备创建设备对象 。  总线驱动程序本质上是同时处理总线枚

JavaWeb系列六: 动态WEB开发核心(Servlet) 上

韩老师学生 官网文档为什么会出现Servlet什么是ServletServlet在JavaWeb项目位置Servlet基本使用Servlet开发方式说明快速入门- 手动开发 servlet浏览器请求Servlet UML分析Servlet生命周期GET和POST请求分发处理通过继承HttpServlet开发ServletIDEA配置ServletServlet注意事项和细节 Servlet注

【Java算法】滑动窗口 下

​ ​    🔥个人主页: 中草药 🔥专栏:【算法工作坊】算法实战揭秘 🦌一.水果成篮 题目链接:904.水果成篮 ​ 算法原理 算法原理是使用“滑动窗口”(Sliding Window)策略,结合哈希表(Map)来高效地统计窗口内不同水果的种类数量。以下是详细分析: 初始化:创建一个空的哈希表 map 用来存储每种水果的数量,初始化左右指针 left

手把手教你入门vue+springboot开发(五)--docker部署

文章目录 前言一、前端打包二、后端打包三、docker运行总结 前言 前面我们重点介绍了vue+springboot前后端分离开发的过程,本篇我们结合docker容器来研究一下打包部署过程。 一、前端打包 在VSCode的命令行中输入npm run build可以打包前端代码,出现下图提示表示打包完成。 打包成功后会在前端工程目录生成dist目录,如下图所示: 把

Sapphire开发日志 (十) 关于页面

关于页面 任务介绍 关于页面用户对我组工作量的展示。 实现效果 代码解释 首先封装一个子组件用于展示用户头像和名称。 const UserGrid = ({src,name,size,link,}: {src: any;name: any;size?: any;link?: any;}) => (<Box sx={{ display: "flex", flexDirecti

ROS2从入门到精通4-4:局部控制插件开发案例(以PID算法为例)

目录 0 专栏介绍1 控制插件编写模板1.1 构造控制插件类1.2 注册并导出插件1.3 编译与使用插件 2 基于PID的路径跟踪原理3 控制插件开发案例(PID算法)常见问题 0 专栏介绍 本专栏旨在通过对ROS2的系统学习,掌握ROS2底层基本分布式原理,并具有机器人建模和应用ROS2进行实际项目的开发和调试的工程能力。 🚀详情:《ROS2从入门到精通》 1 控制插

JavaWeb 学习笔记 spring+jdbc整合开发初步

JdbcTemplate类是Spring的核心类之一,可以在org.springframework.jdbc.core中找到它。JdbcTemplate类在内部已经处理数据库的建立和释放,可以避免一些常见的错误。JdbcTemplate类可直接通过数据源的应用实例化,然后在服务中使用,也可在xml配置中作为JavaBean应用给服务使用直接上一个实例步骤1.xml配置 <?xml version