【发布时间】:2017-10-19 09:13:30
【问题描述】:
我使用 node.js 7.44。
在 user.models.ts 文件中,我有 multilplie 类,例如:
import { Exclude, Expose } from "class-transformer";
export class User {
@Expose() _id: string;
@Expose() fname: string;
@Expose() lname: string;
@Expose() birthday: Date;
@Expose() address: Address;
constructor(){...}
}
@Exclude()
export class Address {
@Expose() street: string;
@Expose() num: number;
@Expose() city: string;
@Expose() zipCode: number;
}
编译服务器时出现错误ReferenceError: Adress is not defined
如何在同一个文件中使用 multilplie 类?
【问题讨论】:
-
先定义类,然后使用。因为提升的概念不适用于类。
-
注意:我认为您应该为每个文件仅导出一个对象,请在此处查看答案:stackoverflow.com/questions/41228221/…
-
Shubham 真的很管用!
标签: javascript node.js typescript class-transformer