枚举在组件中未定义

时间:2019-04-17 09:23:15

标签: angular typescript

我有一个名为waypoint-edit-action.ts的文件

内部,我有以下=>

export declare enum WaypointEditActions {
  INIT = 0,
  MOUSE_MOVE = 1,
  ADD_POINT = 2,
  ADD_LAST_POINT = 3,
  CHANGE_TO_EDIT = 4,
  REMOVE_POINT = 5,
  DRAG_POINT = 6,
  DRAG_POINT_FINISH = 7,
  DRAG_SHAPE = 8,
  DRAG_SHAPE_FINISH = 9,
  DONE = 10,
  DISABLE = 11,
  ENABLE = 12,
  DISPOSE = 13,
  SET_EDIT_LABELS_RENDER_CALLBACK = 14,
  UPDATE_EDIT_LABELS = 15,
  SET_MANUALLY = 16,
  TRANSFORM = 17
}

我尝试通过组件使用此枚举

import { WaypointEditActions } from '../models/waypoint-edit-actions';

WaypointEditActions.INIT

但是它说INIT是不确定的...为什么?

1 个答案:

答案 0 :(得分:1)

尝试从枚举清除中删除decleare关键字-

export enum WaypointEditActions {
     INIT = 0,
     MOUSE_MOVE = 1,
     ADD_POINT = 2,
     ADD_LAST_POINT = 3,
     CHANGE_TO_EDIT = 4,
     REMOVE_POINT = 5,
     DRAG_POINT = 6,
     DRAG_POINT_FINISH = 7,
     DRAG_SHAPE = 8,
     DRAG_SHAPE_FINISH = 9,
     DONE = 10,
     DISABLE = 11,
     ENABLE = 12,
     DISPOSE = 13,
     SET_EDIT_LABELS_RENDER_CALLBACK = 14,
     UPDATE_EDIT_LABELS = 15,
     SET_MANUALLY = 16,
     TRANSFORM = 17
}