我会用 Dashing 为我的仪表板创建一个新的小部件。使用服务器 REST,我会收到一个十六进制代码颜色,我想动态地将它用作小部件的背景颜色。
我的工作,我收到正确的颜色。但我无法动态更改背景颜色。
SCSS代码:
$background-color: #008000; /*default color*/
$title-color: rgba(255, 255, 255, 1);
$moreinfo-color: rgba(255, 255, 255, 0.7);
.widget-state {
background: $background-color;
font-size: 65px;
font-weight: bold;
}
还有我的小部件的咖啡脚本
ready: ->
# This is fired when the widget is done being rendered
onData: (data) ->
# Handle incoming data
# You can access the html node of this widget with `@node`
@accessor 'value', Dashing.AnimatedValue
@accessor 'FCurrentColor', Dashing.AnimatedValue
@accessor 'FCurrentState', Dashing.AnimatedValue
$(@node).fadeOut().css('background-color', @get('FCurrentColor')).fadeIn()
最后一行必须改变背景颜色,不是吗?但它不起作用。