2

我在 NodeJS 上实现的项目中使用了 class-transformer lib,但我没有找到一种方法来公开我的实体的所有属性,我尝试在类级别使用 de @Expose() decrator,但它不起作用,我希望找到类似的解决方案,因为在我的实体中逐个属性地暴露装饰器有点令人筋疲力尽。我想要的例子:

@Expose()
export class User{
   name:string;
   phone:string;
   age:number
};

目前它只在以下情况下工作:

export class User{
   @Expose()  name:string;
   @Expose()  phone:string;
   @Expose()  age:number
};
4

0 回答 0