From 8d355c178c7e181feaef5c906457c96e6eafee7e Mon Sep 17 00:00:00 2001 From: swx1239486 Date: Tue, 5 Sep 2023 20:43:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=A4=9Aakrts=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: swx1239486 --- .../multi-device-app-dev/responsive-layout.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md index 6da55b1e78..ce5f47f69e 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md @@ -52,16 +52,16 @@ ```ts // MainAbility.ts - import type window from '@ohos.window' + import window from '@ohos.window' import display from '@ohos.display' import Ability from '@ohos.app.ability.Ability' export default class MainAbility extends Ability { - private windowObj: window.Window - private curBp: string + private windowObj?: window.Window + private curBp: string = '' //... // 根据当前窗口尺寸更新断点 - private updateBreakpoint(windowWidth) :void{ + private updateBreakpoint(windowWidth: number) :void{ // 将长度的单位由px换算为vp let windowWidthVp = windowWidth / (display.getDefaultDisplaySync().densityDPI / 160) let newBp: string = '' @@ -166,7 +166,7 @@ export class BreakpointType { this.md = md this.lg = lg } - GetValue(currentBreakpoint: string):T { + GetValue(currentBreakpoint: string):T | undefined{ if (currentBreakpoint === 'sm') { return this.sm } @@ -182,9 +182,9 @@ export class BreakpointType { export class BreakpointSystem { private currentBreakpoint: string = 'md' - private smListener: mediaquery.MediaQueryListener - private mdListener: mediaquery.MediaQueryListener - private lgListener: mediaquery.MediaQueryListener + private smListener?: mediaquery.MediaQueryListener + private mdListener?: mediaquery.MediaQueryListener + private lgListener?: mediaquery.MediaQueryListener private updateCurrentBreakpoint(breakpoint: string) :void{ if (this.currentBreakpoint !== breakpoint) { -- GitLab