wsfe / vue-tree

使用虚拟列表优化的 Vue 树组件 Vue tree component optimized using virtual list
https://wsfe.github.io/vue-tree/
MIT License
196 stars 38 forks source link

开启animation报错导致页面卡死 #105

Closed zhoushengdong closed 1 month ago

zhoushengdong commented 2 months ago

Bug 描述 报错:TypeError: Cannot read properties of undefined (reading 'key')导致页面直接卡死,必现的 BUG,因为是G端项目,所以无法提供复测数据

复现步骤 v2版本,当开启 animation 后,数据量大的情况下,不断展开根组织A下的子组织或者子孙组织(展开得足够多时),再展开根组织B后产生报错

组件版本

System Info

System:
 - OS: macOS 13.2.1
 - CPU: (8) arm64 Apple M1 Pro
 - Memory: 41.03 MB / 16.00 GB
 - Shell: 5.8.1 - /bin/zsh

Binaries:
 - Node: 20.16.0 - /opt/homebrew/bin/node
 - Yarn: 1.22.19 - /opt/homebrew/bin/yarn
 - npm: 8.19.4 - /opt/homebrew/bin/npm
 - pnpm: 9.7.1 - /opt/homebrew/bin/pnpm

Browsers:
 - Chrome: 128.0.6613.113
 - Safari: 16.3
ChuChencheng commented 2 months ago

有复现示例么,不用真实的数据

zhoushengdong commented 2 months ago

@ChuChencheng 提供一个可以复现的仓库 demo和步骤:https://github.com/zhoushengdong/demo

https://github.com/user-attachments/assets/f0b6d14d-4e24-4903-abad-1b3c422bcb32

ChuChencheng commented 1 month ago

找到问题了,是展开过程中,从非虚拟列表切换成了虚拟列表,在计算动画用的节点时,渲染节点列表变了(整个列表滚动比较偏上,renderStart 从 0 变成了 20),导致取了重复的节点

@wsfe/ctree v2.4.1 @wsfe/vue-tree v4.1.1