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


效果

 

 上代码

 1 <style>
 2     .s-bg2{  3  backgound:#eee;  4  }  5     .s-c{  6  color:bule;  7  }  8 </style>
 9 
10 // 根据主题色变换树的颜色
11 changeTreeAboutTheme(){ 12   let that = this; 13  that.$nextTick(function(){ 14       //先获取节点
15     let array = document.querySelectorAll('.is-current'); 16     if(array && array.length>0){ 17       for (let i = 0; i < array.length; i++) { 18         const element = array[i]; 19         //将原来的颜色置为无
20         const content = element.querySelectorAll('.el-tree-node__content'); 21         content[0].style.background  = "none"; 22         // 加类,变更
23         if(element.className.indexOf('s-bg2') === -1){ 24           element.className += " s-bg2 s-c"; 25  } 26  } 27  } 28  }) 29 },

 

 

不懂私聊。


免责声明!

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



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