这是MainService中定义的函数.ts,它可以更改badgesColorSet中的 colored颜色 集,我已经在json配置中定义了3种 colored颜色 ,我希望这3种 colored颜色 在每次打开网站时都会更改,让它变为红色,然后刷新页面,它应该是绿色的

getIteriateColor(){
        //gets  color out of color set from turnkey.config file for badges
    let  badgesColorSet = 0; badgesColorSet < Array.length; badgesColorSet++;
        console.log(badgesColorSet);
        return badgesColorSet;

推荐答案

getIteriateColor() {

   if (!this.colorIndex) {
       this.colorIndex = 0;
     } else {
   if  (this.colorIndex + 1 > this.badgesColorSet.length - 1) {
        this.colorIndex = 0
       } else {
     //    this.colorIndex = this.badgesColorSet[1];
     this.colorIndex + 1
       }
     }
     console.log('current color is: ', this.badgesColorSet[this.colorIndex]);
     
     this.colorIndex ++ ;
     return this.badgesColorSet[this.colorIndex];
   }

  
}```

Html相关问答推荐

卸载伪元素 destruct 了CSS

z—index总是 destruct 我的头,我该如何修复它?

如何只混合部分的背景而不是内容<>

为什么XPath返回的元素比我预期的要多?

R-markdown中的非顺序列表

如何将内容元素放在侧边栏旁边?

可以';t使我的导航栏在HTML/CSS中正确对齐

为什么 CSS 网格超出了父级?

如何使背景 colored颜色 逐渐渐变成另一种 colored颜色 ?

Angular:从服务器下载 HTML 并打印

具有 css 高度的输入元素:100% 溢出父 div

如何在Bootstrap卡片底部添加波浪形状

我正在使用 react-router-dom 并创建了一个固定的导航栏,它在每个网页上不断改变大小,我不知道为什么

辅助功能:alt 或 alt="" 用于装饰图像

如何创建带有偏移边框线的双色边框?

当我希望它只横向滚动时,可滚动菜单也会上下移动

AWS SES:如何正确使用 CSS

有没有办法在 CSS 类子句中指定多个 HTML 元素?

粘性定位的子元素忽略父母的填充

如何修复 flex div 以将全高作为其父级