简体   繁体   English

Tslint Angular:不允许使用窗口

[英]Tslint Angular: Usage of window is not allowed

I need to print one of the pages in my Angular app, so I have something like: 我需要在Angular应用程序中打印页面之一,所以我遇到了类似以下情况:

myPage = window.open();
myPage.Print();

The thing is that I get the following error from tslint: 问题是我从tslint收到以下错误:

"Usage of window is not allowed" “不允许使用窗户”

I looked of some answeres here / other solutions, for example: https://brianflove.com/2018/01/11/angular-window-provider/ 我在这里/其他解决方案中找到了一些答案,例如: https : //brianflove.com/2018/01/11/angular-window-provider/

but they all use at some point window 但它们都使用在某些时候window

 return window;

and then I'll get the error messge "Usage of window is not allowed" again. 然后我将再次收到错误消息"Usage of window is not allowed"

How can I solve it ? 我该如何解决?

Thanks. 谢谢。

So I resolved it by instead of do myPage = window.open(); 所以我解决了它,而不是这样做myPage = window.open(); , just do: , 做就是了:

myPage = open(); 

instead ... 相反...

pretty much so easy. 非常简单。

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

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