Vue控制表格的某行/某列显示和隐藏(通用)

需求描述:

想做一个点击按钮可以隐藏表格的某个字段

也可以是根据权限控制某列中显示与隐藏

效果:

全部的表格效果,

《Vue控制表格的某行/某列显示和隐藏(通用)》

点击第一个

《Vue控制表格的某行/某列显示和隐藏(通用)》

参考代码:

场景:根据不同用户(普通用户,vip用户),展示对应的列

思路:将原来的columns copy一份,然后根据权限去让它过滤对应的列,就能返回最新的columns了

created() {
    userType(type) {
      // type: 1 普通用户   2 vip用户  如果是普通用户则不能看到 couponAbleNum 这一列。
      if (type == '1') { //此处判断不用用户类型是否有有对应的列权限
        this.columns = this.columns.filter(col => col.type !== '2' )
        this.columns = this.columns.filter(col => col.type !== '3' )
      } else {
        this.columns = this.columnsCopy
      }
    }
  }

 

    原文作者:陈等等1121
    原文地址: https://blog.csdn.net/chenfengdong/article/details/124277977
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞