语法
🌐 Syntax
@enum [<type>]
概述
🌐 Overview
@enum 标记记录了静态属性的集合,这些属性的值都属于同一类型。
🌐 The @enum tag documents a collection of static properties whose values are all of the same type.
枚举类似于属性的集合,不同之处在于枚举在其自身的文档注释中进行记录,而属性则在其容器的文档注释中进行记录。通常这个标签与 @readonly 一起使用,因为枚举通常表示一组常量。
🌐 An enum is similar a collection of properties, except that an enum is documented in its own doc comment, whereas properties are documented within the doc comment of their container. Often this tag is used with @readonly, as an enum typically represents a collection of constants.
示例
🌐 Examples
这展示了如何记录一个表示具有三种可能状态的值的对象。请注意,如果你愿意,枚举成员可以添加可选的描述。你还可以覆盖类型,如“MAYBE”所示——默认情况下,枚举成员将使用与枚举本身相同的类型进行记录。
🌐 This shows how to document an object that represents a value with three possible states. Note that the enum members can have optional descriptions added if you wish. Also you can override the type, as is shown with "MAYBE" -- by default enum members will be documented with the same type as the enum itself.
/**
* Enum for tri-state values.
* @readonly
* @enum {number}
*/
var triState = {
/** The true value */
TRUE: 1,
FALSE: -1,
/** @type {boolean} */
MAYBE: true
};