我已将角度从 5.2 升级到了 7.2.0 ,并使用了以下版本的软件包:
“ @ angular / flex-layout ”:“ ^ 7.0.0-beta.22 ”,打字稿版本: 3.2.2 ,“ @ angular / cdk ”: 7.2.1 ,“ @ angular / cli : 7.1 .4 ”
我收到一个构建错误:
'MediaQueryListEvent'不能分配为MediaQueryList类型。
export class LayoutComponent implements OnInit, OnDestroy {
private _router: Subscription;
mediaMatcher: MediaQueryList = matchMedia(`(max-width: ${SMALL_WIDTH_BREAKPOINT}px)`);
url: string;
sidePanelOpened;
constructor (
private _element: ElementRef,
private router: Router) {
this.mediaMatcher.addListener(mql => zone.run(() => {
this.mediaMatcher = mql; //i am getting error here Type 'MediaQueryListEvent' is not assignable to type 'MediaQueryList'.
//Property 'onchange' is missing in type 'MediaQueryListEvent'.
}));
}
}
任何人都可以帮助我解决此问题。
答案 0 :(得分:3)
嗨,您可以尝试更改此行
zone.run(() => this.mediaMatcher = mql));
为此
zone.run(() => this.mediaMatcher = matchMedia(`(max-width: ${SMALL_WIDTH_BREAKPOINT}px)`)));