我有一个结构
position.utils.ts
enum PositionDirectionEnum {
LEFT, RIGHT, TOP, BOTTOM, AUTO
}
export class PositionUtil {
public static PositionDirection: PositionDirectionEnum
}
utils.ts
import { PositionUtil } from "./position.util";
export class Utils {
public static Position: PositionUtil = PositionUtil;
}
我想这样用:
Utils.Position.PositionDirection.LEFT
这可能吗?
答案 0 :(得分:2)
你可以这样做:
1)放下position.utils.ts
2)在你的utils.ts中:
export namespace Utils
{
export namespace Position
{
export enum PositionDirection
{
LEFT, RIGHT, TOP, BOTTOM, AUTO
}
}
export class Layout
{
public static Vertical = "vertical";
public static Horizontal = "horizontal";
}
}
3)在你的文件中:
import { Utils } from "./utils";
let p = Utils.Position.PositionDirection.LEFT;
let l = Utils.Layout.Horizontal;