Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

el-table组件如何能通过store.updateColumns更新表头列重绘显示,实现可配置切换显示不同列的效果 #23040

Open
fengjingwork opened this issue Feb 26, 2025 · 0 comments

Comments

@fengjingwork
Copy link

您好,目前有一个已实现的案例,是将el-table源码复制到本地在页面中引用,通过$refs指向table实例调用其store.updateColumns()方法就能有效果,类似以下两种情况当前组件或层级嵌套组件都能触发:
this.$refs.commonTable.$refs.multipleTable.store.updateColumns(['field1']);
this.$refs.multipleTable.store.updateColumns(['field1']);

但是我自己尝试在页面中直接引用npm依赖中的el-table再调用updateColumns始终无法实现效果,单纯是静态demo,已排除异步和dom渲染更新等干扰因素,如下所示:




mounted() {
this.$nextTick(() => {
this.$refs.commonTable.store.updateColumns(['field1']);
})
},

$refs指向在控制台都能正常获取打印出来,.store.updateColumns方法也是存在的,但就是没效果,换成源码table本地引用就好使,实在不明白为什么,难道就是因为引用方式的差异所导致吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant