iframe 跨域加载页面

Angular7中使用iframe动态嵌套页面。

1. html:

 

2. ts: 解决问题:(unsafe value used in a resource URL context)

import { Component, OnInit, Input, OnChanges, SimpleChanges, EventEmitter, Output } from '@angular/core';

import { DomSanitizer } from '@angular/platform-browser'


@Component({
  selector: 'xxx',
  templateUrl: '.xxx.component.html',
  styleUrls: ['./xxx.component.less']
})
export class BoardV2Component implements OnInit, OnChanges {

  href:any;
  constructor(  
    public sanitizer:DomSanitizer
  ) { 
    this.href= this.sanitizer.bypassSecurityTrustResourceUrl('https://xxxxxx');   
  }

 

你可能感兴趣的:(前端,Angular,iframe)