语法
¥Syntax
@access <package|private|protected|public>
概述
¥Overview
@access
标签指定成员的访问级别。你可以使用 @access
标签作为其他标签的同义词:
¥The @access
tag specifies the access level of a member. You can use the @access
tag as a
synonym for other tags:
-
@access package
与@package
相同。此选项在 JSDoc 3.5.0 及更高版本中可用。¥
@access package
is the same as@package
. This option is available in JSDoc 3.5.0 and later. -
@access private
与@private
相同。¥
@access private
is the same as@private
. -
@access protected
与@protected
相同。¥
@access protected
is the same as@protected
. -
@access public
与@public
相同。¥
@access public
is the same as@public
.
除非使用 -p/--private
命令行选项运行 JSDoc,否则私有成员不会显示在生成的输出中。在 JSDoc 3.3.0 及更高版本中,你还可以使用 -a/--access
命令行选项 来更改此行为。
¥Private members are not shown in the generated output unless JSDoc is run with the -p/--private
command-line option. In JSDoc 3.3.0 and later, you can also use the -a/--access
command-line
option to change this behavior.
请注意,doclet 的访问级别与其范围不同。例如,如果 Parent
有一个名为 child
且记录为 @public
的内部变量,则 child
变量仍将被视为名称路径为 Parent~child
的内部变量。换句话说,child
变量将具有内部作用域,即使该变量是公共的。要更改 doclet 的范围,请使用 @instance
、@static
和 @global
标签。
¥Note that a doclet's access level is different from its scope. For example, if Parent
has an
inner variable named child
that is documented as @public
, the child
variable will still be
treated as an inner variable with the namepath Parent~child
. In other words, the child
variable
will have an inner scope, even though the variable is public. To change a doclet's scope, use the
@instance
, @static
, and @global
tags.
示例
¥Examples
/** @constructor */
function Thingy() {
/** @access private */
var foo = 0;
/** @access protected */
this._bar = 1;
/** @access package */
this.baz = 2;
/** @access public */
this.pez = 3;
}
// same as...
/** @constructor */
function OtherThingy() {
/** @private */
var foo = 0;
/** @protected */
this._bar = 1;
/** @package */
this.baz = 2;
/** @public */
this.pez = 3;
}