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 6da55b1e785e4a4db3c69a7e2047c433ac434609..ce5f47f69eeb3459efd9feb3ca58a73b9046bccb 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) {