以下课程:
module LayoutEngine {
enum DocumentFormat {
DOCX = 1
};
export class DocHeader {
public format : DocumentFormat;
}
}
我有两个问题:
谢谢 - 戴夫
答案 0 :(得分:34)
上面有一个编译错误,其中显示"公共财产'格式'导出的类已经或正在使用私有类型' DocumentFormat'。
简单地导出:
module LayoutEngine {
export enum DocumentFormat {
DOCX = 1
};
export class DocHeader {
public format : DocumentFormat;
}
}
有没有办法将枚举声明放在类中?
enum
typescript类型需要在模块级别(文件或模块内)。当然,如果你想在课堂上使用json对象
module LayoutEngine {
export class DocHeader {
DocumentFormat = {
DOCX: 1
};
public format : number;
}
}