Javascript 更新jquery MiniColor rgb的值
我试图设置jquery MiniColor颜色选择器的默认(起始)值,但无法将其设置为任何值。我看到很多示例使用了Javascript 更新jquery MiniColor rgb的值,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我试图设置jquery MiniColor颜色选择器的默认(起始)值,但无法将其设置为任何值。我看到很多示例使用了hex值,但没有一个使用rbg值 我经常遇到这样的错误:“无法读取updateFromInput上未定义的属性'opacity'” opacity:false,不应该是false?是的,应该是。然而,我仍然得到相同的错误。谢谢你发现了! //this value comes from the parent controller and is an object //scope.sta
hex
值,但没有一个使用rbg
值
我经常遇到这样的错误:“无法读取updateFromInput上未定义的属性'opacity'”
opacity:false
,不应该是false
?是的,应该是。然而,我仍然得到相同的错误。谢谢你发现了!
//this value comes from the parent controller and is an object
//scope.startColor = {r: 122, g: 134, b: 100};
var currentColor = 'rgb(' + scope.startColor.r + ',' + scope.startColor.g + ',' + scope.startColor.b + ')';
element.minicolors('value',currentColor);
scope.$watch('startColor', function() {
var currentColor = 'rgb(' + scope.startColor.r + ',' + scope.startColor.g + ',' + scope.startColor.b + ')';
element.minicolors('value',currentColor);
});
element.minicolors({
control: 'wheel',
format: 'rgb',
inline: true,
opacity: false,
change: function(value, opacity) {
var rgb = element.minicolors('rgbObject');
scope.colorUpdated({clr: rgb});
}
});