可以搜索后选中该节点后滚动到选中的节点位置<div style="height:100px;overflow:scroll" ref="treeParent"> <el-tree :data="data" :props="defaultProps" default-expand-all highlight-current node-key="id" ref="tree"> </el-tree> </div>this.$refs.tree.setCurrentKey(7); this.$nextTick(() => { let parent = this.$refs.treeParent; const node = parent.querySelector(".el-tree-node.is-current"); parent.scrollTo({ top: node.offsetTop, behavior:"smooth" }); });
可以搜索后选中该节点后滚动到选中的节点位置