且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从任何RGB组合中获取颜色名称(包括脚本)

更新时间:2023-01-27 14:48:28

由于没有足够的细节,很难给您一个明确的答案-但是,如果您正确地调用了两个外部资源(如果需要,您还需要jQuery'正在使用此方法),那么您应该收到所请求的警报.当您将资源内联(不包括jQuery)时,它的一个小提琴可以正常工作. https://jsfiddle.net/j3gbwvvg/.您不需要jQuery的原因是因为我们将数据直接放入变量中并调用了它,而不是使用利用了.getJSON()jQuery函数的库函数.

Hard to give you a definitive answer as there's not enough detail - but if you're calling the two external resources correctly (you'll also need jQuery if you're using this method), then you should get an alert as requested. Here's a fiddle of it working correctly when you bring the resources inline (which excludes the need for jQuery) https://jsfiddle.net/j3gbwvvg/. The reason you don't need jQuery is because we're putting the data directly into a variable and calling that, not using the library's function which utilises the .getJSON() jQuery function.

window.classifier = new ColorClassifier();
window.classifier.learn(data);
var result_name = window.classifier.classify("#aaf000");
alert(result_name);