允许在JavaScript中使用枚举来定义另一个枚举吗?
var VESSEL_DOCUMENT_SUB_TYPE = {
// PLAN_TYPE : {
//
// },
/** @enum {Number} */
CERTIFICATE_TYPE : {
BUNKER_OIL_POLLUTION_DAMAGE : CERTIFICATE_TYPE.BUNKER_OIL_POLLUTION_DAMAGE,
P_I_COE : CERTIFICATE_TYPE.P_I_COE,
H_M_SINGLE_COVER_NOTE : CERTIFICATE_TYPE.H_M_SINGLE_COVER_NOTE
}/*,
OTHER : {
}*/
};
var CERTIFICATE_TYPE = {
/** Bunker Oil Pollution Damage */
BUNKER_OIL_POLLUTION_DAMAGE : 0,
/** P&I (COE) */
P_I_COE : 1,
/** H&M Single Cover Note */
H_M_SINGLE_COVER_NOTE : 2
};
答案 0 :(得分:2)
是的,这是允许的。唯一的问题是,我收到运行时错误,因为CERTIFICATE_TYPE
应该在VESSEL_DOCUMENT_SUB_TYPE
之前定义
var CERTIFICATE_TYPE = {
/** Bunker Oil Pollution Damage */
BUNKER_OIL_POLLUTION_DAMAGE : 0,
/** P&I (COE) */
P_I_COE : 1,
/** H&M Single Cover Note */
H_M_SINGLE_COVER_NOTE : 2
};
var VESSEL_DOCUMENT_SUB_TYPE = {
// PLAN_TYPE : {
//
// },
/** @enum {Number} */
CERTIFICATE_TYPE : {
BUNKER_OIL_POLLUTION_DAMAGE : CERTIFICATE_TYPE.BUNKER_OIL_POLLUTION_DAMAGE,
P_I_COE : CERTIFICATE_TYPE.P_I_COE,
H_M_SINGLE_COVER_NOTE : CERTIFICATE_TYPE.H_M_SINGLE_COVER_NOTE
}/*,
OTHER : {
}*/
};