JSDoc 中文网

概述

🌐 Overview

@override 标签表示一个符号覆盖了父类中同名的符号。

🌐 The @override tag indicates that a symbol overrides a symbol with the same name in a parent class.

此标签用于与 闭包编译器 的兼容性。默认情况下,JSDoc 会自动识别覆盖父类的符号。

🌐 This tag is provided for compatibility with Closure Compiler. By default, JSDoc automatically identifies symbols that override a parent.

如果你的 JSDoc 注释包含 @inheritdoc 标签,则无需包含 @override 标签。 @inheritdoc 标签的存在意味着 @override 标签的存在。

🌐 If your JSDoc comment includes the @inheritdoc tag, you do not need to include the @override tag. The presence of the @inheritdoc tag implies the presence of the @override tag.

示例

🌐 Example

以下示例显示如何指示某个方法重写其父类中的方法:

🌐 The following example shows how to indicate that a method overrides a method in its parent class:

重写父类的方法
/**
 * @classdesc Abstract class representing a network connection.
 * @class
 */
function Connection() {}

/**
 * Open the connection.
 */
Connection.prototype.open = function() {
    // ...
};


/**
 * @classdesc Class representing a socket connection.
 * @class
 * @augments Connection
 */
function Socket() {}

/**
 * Open the socket.
 * @override
 */
Socket.prototype.open = function() {
    // ...
};