antdesignvue中defaultExpandedRowKeys无效不能展开所有行defaultExpandAllRows也用不了的异步加载解决方案

分析原因:antdesignvue的前端是一次性渲染的,所以defaultExpandedRowKeys等只在渲染时有效。
解决方法:添加判断v-if你的DataSource长度,如果为0则不渲染。
动态解决方法:在DataSource赋值的时候,使用splice将其长度变为0

this.DataSource.splice(0)
		<a-row class="tree-box">
              <a-col>
                <a-tree
                  v-if="DataSource.length>0"
                  v-model="checkedKeys"
                  checkable
                  :auto-expand-parent="autoExpandParent"
                  defaultExpandAll
                  :tree-data="DataSource"
                />
              </a-col>
            </a-row>

猜你喜欢

转载自blog.csdn.net/wwppp987/article/details/113737659
今日推荐