在寫樹形表格的時候我發(fā)現(xiàn)沒有辦法動態(tài)展開和收起表格,在動態(tài)修改default-expand-all的時候值發(fā)生改變了,但是頁面并未有任何改變,很是惆悵。

表格部分.png
<el-table
v-if="refreshTable" //重新渲染表格
ref="userLevel"
:data="userList"
style="width: 100%;margin-bottom: 20px;"
row-key="id"
border
lazy
:load="load"
size="small"
:default-expand-all="expands" //是否展開
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
handleOpen() { //展開
this.refreshTable = false;
this.expands = true;
this.$nextTick(() => {
this.refreshTable = true;
});
},
handleClose() { //收起
this.refreshTable = false;
this.expands = false;
this.$nextTick(() => {
this.refreshTable = true;
});
}

emmmm.png
以上是我完成展開與收起的方法,簡單來說就是重新渲染一下表格,個人意見,不喜勿噴,如果幫助到了你,你可以偷偷給我點個贊。