angular使用iframe的src无效
2021-07-23 本文已影响0人
姜治宇
angular使用iframe比较诡异,直接用src标签是无效的。
//html
<iframe [src]="getUrl(detailData.id)" frameborder="0" width="100%" height="620px"></iframe>
//js
import {DomSanitizer} from "@angular/platform-browser";
getUrl(id){
return this.sanitizer.bypassSecurityTrustResourceUrl(`/share?scene=${id}`);
}