在一个项目中, 有一个需求: 点击一个表格的每一行, 动态设置树节点的选中状态
设置节点的选中状态可以直接使用setCurrentKey方法, 根据node-key设置
this.$refs.tree.setCurrentKey(2);
如果要取消选中状态,只需要设置成null就可以
this.$refs.tree.setCurrentKey(null);
在做取消选中状态时, 原本是使用原生js来移除选中状态的class, 然后报错: Uncaught TypeError: Cannot read property ‘classList’ of undefined, 暂时没找到原因
var ele = document.getElementsByClassName("abc");
ele.classList.remove("is-current");