简体   繁体   English

角材料 - sidenav 组件无法正常工作

[英]Angular material - sidenav component not working correctly

I am developing a web app for different devices : Desktop, Tablet, phone.我正在为不同的设备开发一个网络应用程序:台式机、平板电脑、手机。 I have combined the sidenav and mediaquery ( import {MediaMatcher} from '@ angular / cdk / layout'; ) for the device size detection.我结合了 sidenav 和 mediaquery( import {MediaMatcher} from '@ angular / cdk / layout'; )用于设备大小检测。

When i load a app with a phone size the sidenav opens, but when i change the device size and return to the phone size the sidenav does not open.当我加载具有手机尺寸的应用程序时,sidenav 会打开,但是当我更改设备尺寸并返回手机尺寸时,sidenav 不会打开。

How can I solve the problem?我该如何解决问题?

Link of the bugged app: Editor link被窃听的应用程序的链接编辑器链接

You can make use of Host Listener to listen to window resize event and make the following changes in your app.您可以使用Host Listener来监听窗口大小调整事件并在您的应用程序中进行以下更改。

@HostListener('window:resize', ['$event'])
onResize(event) {
 event.target.innerWidth < 400 ? this.sideNavButtonVisible = true :  this.sideNavButtonVisible = false;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM