我想在页面启动时打开一个新的页面,但我不断收到一个角4 NgOnInitReference错误
Reference Error: Window not defined.
我只开始与打字稿及Angular4最近的工作,所以我不这样确定这个问题真正属于哪一个。
export class HomeComponent implements OnInit {
testCall: Window;
constructor() {
this.testCall = new Window();
this.testCall.open(
"https://static.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg");
}
ngOnInit(): void {
console.log("function read");
window.open("https://static.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg");
}
即使我使用this.testCall.open
的OnInit()
里面,我只得到一个参考错误,但在open
方法。
我知道这是一个简单的页面打开时,第一页打开,但它已经一个星期了,我真的不知道如何在打字稿/ angular4设置中做到这一点。
已经尝试过,没有工作。窗口未定义。 :( – RoboKy
你需要删除该行,如果邮件仍然存在,那么你并没有删除它 – trichetriche
当然,我删除了该行,除了现在它给我“TypeError:无法读取未定义的属性”打开“真的很抱歉对于这个问题 – RoboKy