angular4 iframe不显示src链接页面

时间:2017-11-09 05:53:28

标签: angular iframe

  

模板:

<iframe  width="100%" height="100%"  [src]="url"></iframe>
  

组件:

我已经将网址转换为safeUrl:

ngOnInit() {
  this.url = this.sanitizer.bypassSecurityTrustResourceUrl('https://www.google.com/');
}

但页面仍然没有显示任何内容,请参阅inspect: empty content of the src link

有人知道为什么吗?

1 个答案:

答案 0 :(得分:1)

您的代码是100%罚款

  

问题在于https://www.google.com/,此网址

有关详情,请参阅:

google homepage will not load in an iframe

How to show google.com in an iframe?

以下是它的工作示例:

https://stackblitz.com/edit/angular-iframe

相关问题