Html 角度4-无法;嵌入;Flash.swf文件
我有一个非常简单的AnimationComponent,它的唯一任务是显示一个作为输入提供的.swf文件。HTML模板如下所示:Html 角度4-无法;嵌入;Flash.swf文件,html,angular,flash,Html,Angular,Flash,我有一个非常简单的AnimationComponent,它的唯一任务是显示一个作为输入提供的.swf文件。HTML模板如下所示: <embed [src]="url" width="400" height="300" /> 当输入参数代码设置为“Blob.swf”时,在浏览器中生成的代码如下: import { Component, Input, OnInit } from '@angular/core'; import { DomSanitizer, SafeResourceUr
<embed [src]="url" width="400" height="300" />
当输入参数代码设置为“Blob.swf”时,在浏览器中生成的代码如下:
import { Component, Input, OnInit } from '@angular/core';
import { DomSanitizer, SafeResourceUrl, SafeUrl } from '@angular/platform-browser';
@Component({
selector: 'animation',
templateUrl: './animation.component.html'
})
export class AnimationComponent implements OnInit {
@Input()
private code: string = '';
private url: SafeResourceUrl;
constructor(private sanitizer: DomSanitizer) { }
ngOnInit() {
let url = `/assets/SWF/${this.code}`;
this.url = this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
<embed height="300" width="400" src="/assets/SWF/Blob.swf">
但是会显示一个空框,并且不存在动画。但这就是它变得奇怪的地方。如果我将HTML模板更改为:
<embed height="300" width="400" src="/assets/SWF/Blob.swf">
精明的读者将看到与最初生成的代码完全相同的动画,动画的显示完全符合预期
有人能想一想为什么生成的代码不能正常工作,而当src硬编码时却能正常工作吗?我找到了一个解决方法。我已将模板更改为:如果我将模板更改为您已将值更改为的模板的新值是多少?我找到了一个解决方法。我已更改模板更改为:如果我将模板更改为,您将值更改为的模板的新值是多少?