1,在configxml文件中添加
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
2.html中加入iframe标签
<ion-content >
<iframe id="iframe"
sandbox="allow-scripts allow-top-navigation allow-pointer-lock allow-same-origin allow-popups allow-forms"
[src]="thisUrl" height="100%" width="100%"
>
</iframe>
</ion-content>
3.ts中对thisUrl进行处理
(1)import {DomSanitizer} from "@angular/platform-browser";
(2)在构造器中声明
constructor(public navCtrl: NavController,public domSanitizer: DomSanitizer) { }
(3)使用DomSanitizer对url做处理
ionViewDidLoad() {
this.url = this.domSanitizer.bypassSecurityTrustResourceUrl('https://www.baidu.com');
}