el-tree 树取消高亮

html 复制代码
 <el-tree
          accordion
          ref="treeRef"
          :data="treedata"
          class="treeRef"
          :current-node-key="currentnode"
          :props="defaultProps"
          highlight-current
          node-key="id"
          :default-expanded-keys="[3, 31, 311]"
          @node-click="handleNodeClick"
        >
          <template #default="{ node }">
            <img
              style="margin-right: 5px"
              :src="treeimgComputed(node.data)"
              alt=""
            />
            <p>{{ node.label }}</p>
          </template>
        </el-tree>
javascript 复制代码
const currentnode: any = ref(null);
const treeRef = ref();
const defaultProps = {
  children: "children",
  label: "label",
};
watch(currentnode, (val) => {
  treeRef.value.setCurrentKey(val);
});
const handleNodeClick = (data: any) => {
  // console.log("打印树:", data);
  currentnode.value = data.id;
  
};

主要代码就是取消高亮把currentnode赋值为null;和监听ref数据

javascript 复制代码
currentnode.value = null;

watch(currentnode, (val) => {
  treeRef.value.setCurrentKey(val);
});

const handleNodeClick = (data: any) => {
  // console.log("打印树:", data);
  currentnode.value = data.id;
   
};
相关推荐
纸上的彩虹41 分钟前
半年一百个页面,重构系统也重构了我对前端工作的理解
前端·程序员·架构
be or not to be1 小时前
深入理解 CSS 浮动布局(float)
前端·css
LYFlied1 小时前
【每日算法】LeetCode 1143. 最长公共子序列
前端·算法·leetcode·职场和发展·动态规划
老华带你飞2 小时前
农产品销售管理|基于java + vue农产品销售管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
小徐_23332 小时前
2025 前端开源三年,npm 发包卡我半天
前端·npm·github
C_心欲无痕2 小时前
vue3 - 类与样式的绑定
javascript·vue.js·vue3
GIS之路3 小时前
GIS 数据转换:使用 GDAL 将 Shp 转换为 GeoJSON 数据
前端
JIngJaneIL3 小时前
基于springboot + vue房屋租赁管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
天天扭码3 小时前
以浏览器多进程的角度解构页面渲染的整个流程
前端·面试·浏览器
你们瞎搞3 小时前
Cesium加载20GB航测影像.tif
前端·cesium·gdal·地图切片