上代碼
<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"; } } } }) },