-1

我想为函数中常用的语句构建一个通用类。

如果我在函数中使用这个关键字,我会得到错误。

 import {Component}  from '@angular/core';
    import { DomSanitizer } from '@angular/platform-browser';
    export class CommonFunctions  {
        
        constructor(private  sanitizer: DomSanitizer){
    
        }
        static sum(a: number, b: number): number {
            return a + b;
        }
     
        static formatImage(projectList:any):any  {
            
          
            for (var index in projectList) {
                let images = projectList[index].img;
                let objectURL = 'data:image/jpeg;base64,' + images;
//error in this line
                let thumbnail1 = this.bypassSecurityTrustUrl(objectURL);
               projectList[index].img = thumbnail1;
        
              }
              return projectList;
            
          }




}
4

1 回答 1

1

它应该是 :

this.sanitizer.bypassSecurityTrustUrl(...)

代替

this.bypassSecurityTrustUrl(...)
于 2020-12-31T07:33:56.227 回答