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;
   
};
相关推荐
Aliex_git4 分钟前
性能指标笔记
前端·笔记·性能优化
秋天的一阵风4 分钟前
🌟 藏在 Vue3 源码里的 “二进制艺术”:位运算如何让代码又快又省内存?
前端·vue.js·面试
松涛和鸣5 分钟前
48、MQTT 3.1.1
linux·前端·网络·数据库·tcp/ip·html
helloworld也报错?6 分钟前
保存网页为PDF
前端·javascript·pdf
渡我白衣6 分钟前
计算机组成原理(13):多路选择器与三态门
开发语言·javascript·ecmascript·数字电路·计算机组成原理·三态门·多路选择器
码丁_1176 分钟前
某it培训机构前端三阶段react及新增面试题
前端·react.js·前端框架
石小石Orz7 分钟前
自定义AI智能体扫描内存泄漏代码
前端·ai编程
汐泽学园7 分钟前
基于Vue的家乡旅游美食信息网站设计与实现
javascript·vue.js·html·旅游·美食
_木棠7 分钟前
uniapp:H5端reLaunch跳转后,返回还有页面存在问题
前端·uni-app
_pengliang21 分钟前
react native ios 2个modal第二个不显示
javascript·react native·react.js