我会更喜欢使用友好的名字并修复错误
<iframe
*ngFor="let trustedLink of trustedVideoUrlArray"
width="100%"
height="315"
[src]="trustedLink"
frameborder="0"
allowfullscreen
></iframe>
import { Component, OnInit } from '@angular/core';
import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
import { NavController } from '@ionic/angular';
@Component({
selector: 'app-help',
templateUrl: './help.page.html',
styleUrls: ['./help.page.scss'],
})
export class HelpPage implements OnInit {
trustedVideoUrlArray: SafeResourceUrl[] = [];
youtubeUrlsArray = [
{
link: "https://www.youtube.com/embed/ytLZo1RBS5U"
},
{
link: "https://www.youtube.com/embed/ytLZo1RBS5U"
}
]
constructor(
public navCtrl: NavController,
private domSanitizer: DomSanitizer
) { }
ngOnInit() {
for (let item of this.youtubeUrlsArray) {
this.trustedVideoUrlArray.push(this.domSanitizer.bypassSecurityTrustResourceUrl(item.link));
}
}
}