您需要先 登录 才能评论/回答

全部评论(2)
可以通过getWindowProperties这个接口获取窗口属性,窗口属性的windowRect是窗口的尺寸。
import window from '@ohos.window';
//获取窗口对象
let windowClass = await window.getLastWindow(getContext());
//获取窗口属性
let properties = windowClass.getWindowProperties();
//获取窗口宽高
console.log("width: "+ properties.windowRect.width);
console.log("height: "+ properties.windowRect.height);

2024-01-30 13:47:53