我在玩流星的“thospaeth:色彩窃贼”包。我所做的就是安装这个包,然后在事件处理程序中定义一个变量:
var colorThief = new ColorThief();错误是
"Exception in template helper: ReferenceError: ColorThief is not defined
at Object.Template.onePiece.helpers.image (http://localhost:3000/test.js?5fb2bf210aaa5b8ff2677599dea86a243ed2c4ef:689:27)
at bindDataContext (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2880:16)
at Blaze._wrapCatchingExceptions (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1651:16)
at http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2928:66
at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12)
at wrapHelper (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2927:27)
at Spacebars.call (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:18)
at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:109:25)
at Object.Spacebars.mustache (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:113:39)
at null._render (http://localhost:3000/template.test.js?99a11da3988b8831f8e1fc0dcbf93b61fa67d909:281:22)"我尝试了另一个程序包“benan789:color- package”。它没有起作用。我尝试将colorthief.js复制到文件夹中,然后直接将其包含在标题中。它也不起作用。
我错过什么了吗?提前感谢你的帮助。
发布于 2015-09-16 10:34:54
我也不能让thospaeth:颜色窃贼工作,但是Benan789:颜色窃贼工作。请注意meteor使用说明(https://atmospherejs.com/benan789/color-thief):
新变量colorThief =
ColorThief.colorRob();
您的事件处理程序可能如下所示:
'click button': function () {
var colorThief = new ColorThief.colorRob();
// get a handle on an image element
var headerImage = $('img.headerimage')[0];
// get the dominant color from the image
var c = colorThief.getColor(headerImage);
console.log('color: ' + c);
}https://stackoverflow.com/questions/32597608
复制相似问题