0
我正在尝试这个libarary调用vibrant.js,我们可以获取图像的颜色样本。我已经成功实施了一套图像。当我试图做同样的另一组图像错误是弹出。我无法弄清楚什么是错的。
我歌厅以下错误之一vibrant.js获取图像数据
Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source height is 0.
或
Uncaught TypeError: Cannot read property 'getHex' of undefined
从这个我认为这是一些错误的图像加载。所以我使用下面的代码来弄清楚发生了什么。
var img = new Image($(this)); // creating image element
img.onload = function() { // trigger if the image was loaded
console.log($(this).attr('src') + ' - done!');
}
img.onerror = function() { // trigger if the image wasn't loaded
console.log($(this).attr('src') + ' - error!');
}
img.onAbort = function() { // trigger if the image load was abort
console.log($(this).attr('src') + ' - abort!');
}
为此,控制台中不显示任何内容。但是,如果我只是使用这些代码没有任何功能,我可以看到日志中的URL。
我一直在尝试这个小时。任何人有任何建议或任何想法,我错了。
注:所有功能被称为$(window).load