使用jsdoc时出现一些问题
'use strict';
/**
* ImagePreloader is a tool for multi-images preloading
*
* @example
* new ImagePreloader(['http://image1.jpg', 'http://image2.jpg'], function (oImage, this.aImages, this.nProcessed, this.nLoaded) {
* //use jQuery
* $('<img>').attr('src', oImage.src);
* });
*
* @author nhnst Liuming
* @version 20110623.4
* @constructor
* @param {String[]} images A collection of images url for preloading
* @param {Function} callback(oImage, this.aImages, this.nProcessed, this.nLoaded) A function to call once the every image request finishes
*/
function ImagePreloader(images, callback) {
this.callback = callback;
this.nLoaded = 0;
this.nProcessed = 0;
this.aImages = [];
this.nImages = images.length;
for (var i = 0, len = images.length ; i < len ; i += 1) {
this.preload(images[i], i);
}
}
/**
* Initialization
* @private
*/
ImagePreloader.prototype.preload = function (image, index) {
var oImage = new Image;
oImage.nIndex = index;
oImage.bLoaded = false;
oImage.oImagePreloader = this;
oImage.src = image + '?flush=' + (+new Date());
this.aImages.push(oImage);
// handle ie cache
if (oImage.width > 0) {
this.onload.call(oImage);
}
else {
oImage.onload = this.onload;
oImage.onerror = this.onerror;
oImage.onabort = this.onabort;
}
};
/**
* A inner function to be called when every image request finishes
* @private
*/
ImagePreloader.prototype.onComplete = function (oImage) {
this.nProcessed++;
this.callback(oImage, this.aImages, this.nProcessed, this.nLoaded);
};
/**
* A inner function to be called when image loads successful
* @private
*/
ImagePreloader.prototype.onload = function () {
this.bLoaded = true;
this.oImagePreloader.nLoaded++;
this.oImagePreloader.onComplete(this);
};
/**
* A inner function to be called when an error occurs loading the image
* @private
*/
ImagePreloader.prototype.onerror = function () {
this.bError = true;
this.oImagePreloader.onComplete(this);
};
/**
* A inner function to be called when image loading is aborted
* @private
*/
ImagePreloader.prototype.onabort = function () {
this.bAbort = true;
this.oImagePreloader.onComplete(this);
};
当我使用jsdoc生成doc文件时,出现一些警告,
>> WARNING: Trying to document ImagePreloader#onload without first documenting I
magePreloader.
>> WARNING: Trying to document ImagePreloader#onerror without first documenting
ImagePreloader.
>> WARNING: Trying to document ImagePreloader#onabort without first documenting
ImagePreloader.
3 warnings.
为什么?
'use strict';
/**
* ImagePreloader is a tool for multi-images preloading
*
* @example
* new ImagePreloader(['http://image1.jpg', 'http://image2.jpg'], function (oImage, this.aImages, this.nProcessed, this.nLoaded) {
* //use jQuery
* $('<img>').attr('src', oImage.src);
* });
*
* @author nhnst Liuming
* @version 20110623.4
* @constructor
* @param {String[]} images A collection of images url for preloading
* @param {Function} callback(oImage, this.aImages, this.nProcessed, this.nLoaded) A function to call once the every image request finishes
*/
function ImagePreloader(images, callback) {
this.callback = callback;
this.nLoaded = 0;
this.nProcessed = 0;
this.aImages = [];
this.nImages = images.length;
for (var i = 0, len = images.length ; i < len ; i += 1) {
this.preload(images[i], i);
}
}
/**
* Initialization
* @private
*/
ImagePreloader.prototype.preload = function (image, index) {
var oImage = new Image;
oImage.nIndex = index;
oImage.bLoaded = false;
oImage.oImagePreloader = this;
oImage.src = image + '?flush=' + (+new Date());
this.aImages.push(oImage);
// handle ie cache
if (oImage.width > 0) {
this.onload.call(oImage);
}
else {
oImage.onload = this.onload;
oImage.onerror = this.onerror;
oImage.onabort = this.onabort;
}
};
/**
* A inner function to be called when every image request finishes
* @private
*/
ImagePreloader.prototype.onComplete = function (oImage) {
this.nProcessed++;
this.callback(oImage, this.aImages, this.nProcessed, this.nLoaded);
};
/**
* A inner function to be called when image loads successful
* @private
*/
ImagePreloader.prototype.onload = function () {
this.bLoaded = true;
this.oImagePreloader.nLoaded++;
this.oImagePreloader.onComplete(this);
};
/**
* A inner function to be called when an error occurs loading the image
* @private
*/
ImagePreloader.prototype.onerror = function () {
this.bError = true;
this.oImagePreloader.onComplete(this);
};
/**
* A inner function to be called when image loading is aborted
* @private
*/
ImagePreloader.prototype.onabort = function () {
this.bAbort = true;
this.oImagePreloader.onComplete(this);
};
when I generate doc file using jsdoc, some warnnings occur
>> WARNING: Trying to document ImagePreloader#onload without first documenting I
magePreloader.
>> WARNING: Trying to document ImagePreloader#onerror without first documenting
ImagePreloader.
>> WARNING: Trying to document ImagePreloader#onabort without first documenting
ImagePreloader.
3 warnings.
why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议将 @name 和 @class 添加到 ImagePreloader:
I would suggest adding @name and @class to ImagePreloader: