JSDoc 中文网

概述

🌐 Overview

提供一个如何使用已记录项目的示例。此标签之后的文本将显示为高亮代码。

🌐 Provide an example of how to use a documented item. The text that follows this tag will be displayed as highlighted code.

示例

🌐 Examples

请注意,一个 doclet 可能有多个示例。

🌐 Note that a doclet may have multiple examples.

记录示例
/**
 * Solves equations of the form a * x = b
 * @example
 * // returns 2
 * globalNS.method1(5, 10);
 * @example
 * // returns 3
 * globalNS.method(5, 15);
 * @returns {Number} Returns the value of x for the equation.
 */
globalNS.method1 = function (a, b) {
    return b / a;
};

Examples can also be captioned using <caption></caption> after the @example tag.

用标题记录示例
/**
 * Solves equations of the form a * x = b
 * @example &lt;caption>Example usage of method1.&lt;/caption>
 * // returns 2
 * globalNS.method1(5, 10);
 * @returns {Number} Returns the value of x for the equation.
 */
globalNS.method1 = function (a, b) {
    return b / a;
};