JSDoc 中文网

Synonyms

语法

¥Syntax

{@link namepathOrURL} [link text]{@link namepathOrURL}

概述

¥Overview

{@link} 内联标记创建指向你指定的名称路径或 URL 的链接。当你使用 {@link} 标记时,你还可以使用几种不同格式之一提供链接文本。如果你不提供任何链接文本,JSDoc 将使用名称路径或 URL 作为链接文本。

¥The {@link} inline tag creates a link to the namepath or URL that you specify. When you use the {@link} tag, you can also provide link text, using one of several different formats. If you don't provide any link text, JSDoc uses the namepath or URL as the link text.

如果你需要链接到教程,请使用 {@tutorial} 内嵌标签 而不是 {@link} 标签。

¥If you need to link to a tutorial, use the {@tutorial} inline tag instead of the {@link} tag.

链接格式

¥Link formatting

默认情况下,{@link} 生成标准 HTML 锚标记。但是,你可能更喜欢以等宽字体呈现某些链接,或者指定各个链接的格式。你可以使用 {@link} 标记的以下同义词来控制链接的格式:

¥By default, {@link} generates standard HTML anchor tags. However, you may prefer to render certain links in a monospace font, or to specify the format of individual links. You can use the following synonyms for the {@link} tag to control the formatting of links:

你还可以在 JSDoc 的配置文件中设置以下选项之一;详细信息请参见 配置 JSDoc

¥You can also set one of the following options in JSDoc's configuration file; see Configuring JSDoc for more details:

注意:尽管默认的 JSDoc 模板可以正确呈现所有这些标签,但其他模板可能无法识别 {@linkcode}{@linkplain} 标签。此外,其他模板可能会忽略链接呈现的配置选项。

¥Note: Although the default JSDoc template renders all of these tags correctly, other templates may not recognize the {@linkcode} and {@linkplain} tags. In addition, other templates may ignore the configuration options for link rendering.

示例

¥Examples

以下示例显示了为 {@link} 标记提供链接文本的所有方法:

¥The following example shows all of the ways to provide link text for the {@link} tag:

提供链接文本
/**

 * See {@link MyClass} and [MyClass's foo property]{@link MyClass#foo}.

 * Also, check out {@link http://www.google.com|Google} and

 * {@link https://github.com GitHub}.
 */
function myFunction() {}

默认情况下,上面的示例会生成类似于以下内容的输出:

¥By default, the example above produces output similar to the following:

“{@link} 标签的输出”
See <a href="MyClass.html">MyClass</a> and <a href="MyClass.html#foo">MyClass's foo
property</a>. Also, check out <a href="http://www.google.com">Google</a> and
<a href="https://github.com">GitHub</a>.

如果配置属性 templates.cleverLinks 设置为 true,则上面的示例将产生以下输出:

¥If the configuration property templates.cleverLinks were set to true, the example above would produce the following output:

启用智能链接的输出
See <a href="MyClass.html"><code>MyClass</code></a> and <a href="MyClass.html#foo">
<code>MyClass's foo property</code></a>. Also, check out
<a href="http://www.google.com">Google</a> and <a href="https://github.com">GitHub</a>.