2016-02-29 32 views
1
/** 
* Returns the sum of all numbers passed to the function. 
* @example 
* sum([1,2,3]) 
* //returns 6 
* sum(1,2,3) 
* //returns 6 
* @param {number[]|...number} params - ??? 
*/ 
function sum(params) { 
    var args = params instanceof Array ? params : arguments; 
    for (var i = 0, sum = 0; i < args.length; i++) 
     sum += args[i]; 
    return sum; 
} 

'PARAMS' 可以是一個陣列或可重複號碼如何使用可重複的參數指示多個類型參數?

但 「@參數{數[] | ...數}」 不工作。

書面文件輸出有沒有什麼區別「@參數{號碼[] |數}」

這是表明在這種情況下,最好的方法是什麼?

回答

0

訣竅是使用括號。我在工作中使用了以下內容。

* @param {...(object|string)} col - An optional set of columns to select. 

更新了你的參數名稱,這應該工作:

* @param {...(number[]|number)} params - ??? 

我找不到括號的任何文件,但在JSDoc 3.4.2,做的伎倆。

此評論:

/** 
* Select columns manually. 
* @param {...(object|string)} col - An optional set of columns to select. 
* Each argument can either be a fully-qualified column name in the form 
* &lt;table-alias&gt;.&lt;column-name&gt;, or an object with the following 
* properties below. If no columns are specified, then all columns are 
* selected. 
* @param {string} col.column - The fully-qualified column name. 
* @param {string} col.mapTo - The name of the property that the column 
* should be mapped to in the resulting normalized object. @param 
* @param {function} col.convert - A converter function that takes a single value 
* from the database and transforms it. For example, a function that 
* converts a bit from the database to a boolean value. 
* @return {this} 
*/ 

息率本文檔:

enter image description here

希望幫助!