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;
   
};
相关推荐
好大哥呀2 小时前
Java Web的学习路径
java·前端·学习
计算机毕设VX:Fegn08952 小时前
计算机毕业设计|基于springboot + vue动物园管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
HashTang2 小时前
【AI 编程实战】第 7 篇:登录流程设计 - 多场景、多步骤的优雅实现
前端·uni-app·ai编程
北辰alk2 小时前
深入理解Vue数据流:单向与双向的哲学博弈
vue.js
cos2 小时前
Fork 主题如何更新?基于 Ink 构建主题更新 CLI 工具
前端·javascript·git
小满zs2 小时前
Next.js第二十一章(环境变量)
前端·next.js
C***11503 小时前
Spring aop 五种通知类型
java·前端·spring
北辰alk3 小时前
解决Vue打包后静态资源图片失效的终极指南
vue.js
朝阳393 小时前
前端项目的【package-lock.json】详解
前端