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;
   
};
相关推荐
土豆125016 分钟前
Tauri 入门与实践:用 Rust 构建你的下一个桌面应用
前端·rust
惜茶1 小时前
vue+SpringBoot(前后端交互)
java·vue.js·spring boot
小陈工2 小时前
2026年4月2日技术资讯洞察:数据库融合革命、端侧AI突破与脑机接口产业化
开发语言·前端·数据库·人工智能·python·安全
IT_陈寒2 小时前
Vue的这个响应式问题,坑了我整整两小时
前端·人工智能·后端
HIT_Weston2 小时前
41、【Agent】【OpenCode】本地代理分析(五)
javascript·人工智能·opencode
C澒2 小时前
AI 生码:A 类生码方案架构升级
前端·ai编程
前端Hardy3 小时前
前端必看!LocalStorage这么用,再也不踩坑(多框架通用,直接复制)
前端·javascript·面试
前端Hardy3 小时前
前端必看!前端路由守卫这么写,再也不担心权限混乱(Vue/React通用)
前端·javascript·面试
Lee川3 小时前
从零构建现代化登录界面:React + Tailwind CSS 前端工程实践
前端·react.js
Awu12273 小时前
⚡精通 Claude 第 1 课:掌握 Slash Commands
前端·人工智能·ai编程