加载中...

@implements


描述: 这个标识实现一个接口。

版本: '>=3.3.0'

Syntax(语法)

@implements {typeExpression}

Overview(概述)

@implements标签指示一个标识实现一个接口。

添加@implements标签到实现接口(例如,一个构造函数)的顶层标识。不需要将@implements标签添加到实现接口(例如,实现的实例方法)的每个成员上。

如果你没有在实现的接口中描述这个标识,JSDoc会自动使用该接口文档的标识。

Examples(例子)

在下面的例子中,TransparentColor类实现Color接口,并添加了TransparentColor#rgba方法。

例如,使用@implements标签:

  1. /**
  2. * Interface for classes that represent a color.
  3. *
  4. * @interface
  5. */
  6. function Color() {}
  7.  
  8. /**
  9. * Get the color as an array of red, green, and blue values, represented as
  10. * decimal numbers between 0 and 1.
  11. *
  12. * @returns {Array<number>} An array containing the red, green, and blue values,
  13. * in that order.
  14. */
  15. Color.prototype.rgb = function() {
  16. throw new Error('not implemented');
  17. };
  18.  
  19. /**
  20. * Class representing a color with transparency information.
  21. *
  22. * @class
  23. * @implements {Color}
  24. */
  25. function TransparentColor() {}
  26.  
  27. // inherits the documentation from `Color#rgb`
  28. TransparentColor.prototype.rgb = function() {
  29. // ...
  30. };
  31.  
  32. /**
  33. * Get the color as an array of red, green, blue, and alpha values, represented
  34. * as decimal numbers between 0 and 1.
  35. *
  36. * @returns {Array<number>} An array containing the red, green, blue, and alpha
  37. * values, in that order.
  38. */
  39. TransparentColor.prototype.rgba = function() {
  40. // ...
  41. };


还没有评论.