Closed xtuer closed 1 year ago
没有失效啊,这边我限制了渲染 30 个节点,实际 block area 子节点个数 32 个,减去头尾两个撑高度的,刚好是 30 个。 检查一下你的树组件外层的容器是不是没有给一个高度,虚拟列表计算是需要拿到 scroll area 这个 div 的 clientHeight 的。
https://codesandbox.io/p/sandbox/vue-tree-render-node-amount-yyt2v5
没有失效啊,这边我限制了渲染 30 个节点,实际 block area 子节点个数 32 个,减去头尾两个撑高度的,刚好是 30 个。 检查一下你的树组件外层的容器是不是没有给一个高度,虚拟列表计算是需要拿到 scroll area 这个 div 的 clientHeight 的。
https://codesandbox.io/p/sandbox/vue-tree-render-node-amount-yyt2v5
问题解决,非常感谢。我直接把 vue-tree 放到最顶层容器里测试,没有设置高度,导致会渲染所有节点,设置高度后就生效了。
例如
<Vtree ref="tree" :load="loadNodes" :render="nodeRender" :renderNodeAmount="100"/>
:renderNodeAmount + bufferNodeAmount
节点,然后在滚动的时候动态生成 DOM 节点。<div class="ctree-tree__block-area"><div style="height: 0px">
中 height 的值一直是0px
,而在线例子 https://wsfe.github.io/vue-tree/ 的 performance 里的这个节点的 height 会变化。造成虚拟滚动不生效的会不会是动态加载的节点都不能使用虚拟滚动了?