naive-ui icon indicating copy to clipboard operation
naive-ui copied to clipboard

n-tree组件在开启virtual-scroll虚拟滚动,并且设置default-expand-all="true"默认展开所有节点时渲染报错

Open xtito opened this issue 7 months ago • 1 comments

Describe the bug

在使用n-tree组件过程中,设置虚拟滚动virtual-scroll,并且设置default-expand-all="true"默认展开所有节点时,页面树节点渲染失败。

特别说明:使用官网示例中的部分数据时,可以正常渲染。使用我示例中的数据时无法渲染。

Image

Steps to reproduce

1、创建一个测试页面,在页面中引用n-tree组件,一定要设置block-line、virtual-scroll、data和default-expand-all="true"; 2、定义树节点数据数组:const treeData = reactive([]); 3、定义树节点选中节点数组:const nodeSelectedKeys = reactive([]); 4、定义页面挂载时加载数据,调用加载数据接口; 5、在加载数据函数中,获取到数据后,赋值给treeData;

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-t1uxeglc?file=src%2FApp.vue

System Info

操作系统:macOs Big Sur 11.7.10
浏览器:Google Chrome 135.0.7049.86
naive-ui版本:2.41.0

Used Package Manager

pnpm

Validations

xtito avatar Apr 25 '25 10:04 xtito

Provide a based on Playground or CodeSandbox or stackblitz `s MinimalReproducible Example

jahnli avatar Jun 08 '25 16:06 jahnli