建议收藏:vue项目-更改el-tree根据主题色变化,变更选中节点的颜色和背景色


 

 

上代码

 

<style>
    .s-bg2{
        backgound:#eee;
    }
    .s-c{
        color:bule;
    }
</style>

// 根据主题色变换树的颜色
changeTreeAboutTheme(){
  let that = this;
  that.$nextTick(function(){
      //先获取节点
    let array = document.querySelectorAll('.is-current');
    if(array && array.length>0){
      for (let i = 0; i < array.length; i++) {
        const element = array[i];
        //将原来的颜色置为无
        const content = element.querySelectorAll('.el-tree-node__content');
        content[0].style.background  = "none";
        // 加类,变更
        if(element.className.indexOf('s-bg2') === -1){
          element.className += " s-bg2 s-c";
        }
      }
    }
  })
},

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM