使用angular,href莫名其妙多了unsafe
解决方法:
ts文件中添加以下代码:
import {DomSanitizer} from '@angular/platform-browser';
...
constructor(private sanitizer:DomSanitizer){}
...
sanitize(url:string){
return this.sanitizer.bypassSecurityTrustUrl(url);
}
html
<a [href]="sanitize('blob:http://www.localhost:8080/a80ed532-27c6-4a2e-a6da-96b25887ef86')">
...
</a>
参考博客: