如果我将函数定义为变量对象,那么 PhpStorm 将显示
item
参数的自动完成。
/**
* @param {Rules.FolderGroupItem} item
**/
var forEach = function(item) {
if(item.type == 'label')
{
str += this.renderLabel(item.paramType);
}
if(item.type == 'input')
{
str += this.renderInput(item.paramType);
}
};
_.each(items,forEach,this);
如果我为
_.each()
函数编写相同的内容作为内联参数。然后就不行了。
_.each(items,forEach,
/**
* @param {Rules.FolderGroupItem} item
**/
function(item)
{
if(item.type == 'label')
{
str += this.renderLabel(item.paramType);
}
if(item.type == 'input')
{
str += this.renderInput(item.paramType);
}
});
我找到了答案。在这里。
_.each(items,forEach,function(/*Rules.FolderGroupItem*/item)
{
if(item.type == 'label')
{
str += this.renderLabel(item.paramType);
}
if(item.type == 'input')
{
str += this.renderInput(item.paramType);
}
});
我必须在评论开头写一个double
**
才能工作。
使用 PhpStorm 2022.3.2,构建 #PS-223.8617.59。/**
*
* @type {Array<Assignment>}
*/
let arr = [];
_.each(arr, /**Assignment*/ itemInArray => {
});