[英]JavaScript class has setter that returns this. How do I document this in JsDoc?
樣例代碼:
var myObject = (function() {
var M;
M = function() {
}
M.prototype = {
constructor: M,
setSomeProperty = function(someValue) {
// Do Stuff
return this; // For chaining purposes
}
}
return M
}());
在記錄setSomeProperty
方法時, @returns
標記setSomeProperty
?
它看起來像這樣:
@returns {M} <code>this</code>
{M}
指示所返回內容的類別,而<code>this</code>
清楚地指示所返回內容。 如果您使用markdown插件:
@returns {M} `this`
更詳細的版本是:
@returns {M} The instance on which this method was called.
或者,您可以省略課程信息,然后讓讀者進行推斷。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.