如何使用angular2 rc.6在显示pdf的embed html标签上禁用sanitize
发布时间:2020-12-17 17:01:51 所属栏目:安全 来源:网络整理
导读:我真的不明白我在做错了什么: 模板: embed [src]="pdfUrl" width="500" height="100%" type='application/pdf' 类: pdfURL;constructor(private domSanitizer : DomSanitizer) {}ngOnInit() { this.pdfUrl = this.domSanitizer.bypassSecurityTrustUrl('h
我真的不明白我在做错了什么:
模板: <embed [src]="pdfUrl" width="500" height="100%" type='application/pdf'> 类: pdfURL; constructor(private domSanitizer : DomSanitizer) {} ngOnInit() { this.pdfUrl = this.domSanitizer.bypassSecurityTrustUrl('http://example.com/pdf.pdf') } 这实际上不会加载< embed>但不会抛出错误. 我在pdfURL和bypassSecurityTrustResourceUrl()上使用SafeUrl类型尝试了它. 解决方法
我认为它应该是:
this.pdfUrl = this.domSanitizer.bypassSecurityTrustResourceUrl('url') 并使用它像: <iframe [src]="pdfUrl" width="500" height="600" type='application/pdf'></iframe> 见Plunkr 更新(Chrome中的嵌入代码存在错误) 对于embed标记,您可以通过outerHTML重新注入embed标记: this.renderer.setElementProperty(el,'outerHTML',el.outerHTML) 对于这种情况,请参见plunker (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- axis2服务发布与客户端代码示例
- 如何使用Twitter的Bootstrap popovers的jQuery验证通知?
- 在debian系统下面编译ICE-3.3
- 下拉菜单 – 移动设备上的非折叠bootstrap 3下拉菜单
- angularjs – 对如何处理CORS OPTIONS预检要求感到困惑
- bootstrap select2插件用ajax来获取和显示数据的实例
- AngularJS – jQueryUI滑块值模型上的反射
- angular – 如何在Ionic 2/3中编写自定义组件而不会丢失准备
- twitter-bootstrap – 使用bootstrap 3中的glyphicon-faceb
- 我心中的十大信息化软件开发技术(转)