Polymer 1.0 - 使用属性绑定CSS类

Jér*_*tel 5 javascript css polymer

我尝试paper-progress使用my属性的值将CSS类绑定到a ,以更改项的颜色.我将我的代码基于GitHub上的Polymer示例和数据绑定文档.

这是我的代码:http://jsbin.com/bidebe/10/edit?html,output

该类的paper-progress更改正确,但颜色没有.如果我直接输入类颜色,颜色是正确的.

所以我不明白为什么我paper-progress有好班级但不适用它.如果有人能帮我理解,谢谢.

小智 2

这也许会对你有帮助。

     attached: function () {
            this.async(function () {
                var paperProgressArray = this.querySelectorAll('paper-progress');//get all paper-progress
                var i = 0;
                var j = paperProgressArray.length;

                var color;
                var secundary;
                var paperProgress;
                var dificulty;
                while (i < j) {
                    paperProgress = paperProgressArray[i];
                    dificulty = paperProgress.value;
                    if (0 <= dificulty && dificulty <= 4) {
                        color = 'red';
                        secundary = "green";
                    } else if (4 < dificulty && dificulty <= 7) {
                        color = 'green';
                        secundary = "red";
                    } else if (7 < dificulty && dificulty <= 10) {
                        color = 'yellow';
                        secundary = "green";
                    }
                       //set and update colors
                    paperProgress.customStyle['--paper-progress-active-color'] = color;
                    paperProgress.customStyle['--paper-progress-secondary-color'] = secundary;
                    this.updateStyles();
                     i++;
                    }
                });
            },
Run Code Online (Sandbox Code Playgroud)