我已经创建了一个使用角度材料和角度flex布局的角度应用程序。这个应用程序的问题是,每当我在chrome中按下Ctrl+P键时,导航栏中的所有菜单都消失了,而应该只出现在移动设备中的菜单按钮出现了,最重要的是,整个应用程序变得无法使用。我必须刷新浏览器,使应用程序可重用。我从angular flex布局的github问题页面中读到,当打印对话框出现时,UI线程会中断,因此出现了问题。有没有解决这个问题的办法。
我已经创建了一个git repo相同的“角度响应Navbar”,这样任何人都可以复制这个问题。
在打印对话框关闭后,恢复MediaMarshaller中的活动断点存在一些问题。您可以使用下面的代码进行临时修复。
export class CommonMaterialModule {
lastValue;
public constructor (
m: MediaMarshaller,
) { // @ts-ignore
m.subject.subscribe((x) => {
// @ts-ignore
if (m.activatedBreakpoints.filter((b) => b.alias === 'print').length === 0) {
// @ts-ignore
this.lastValue = [...m.activatedBreakpoints];
} else {
// @ts-ignore
m.activatedBreakpoints = [...this.lastValue];
// @ts-ignore
m.hook.collectActivations = () => {};
// @ts-ignore
m.hook.deactivations = [...this.lastValue];
}
});
}
}
详解请参考此链接。