ElementUI的表格展开 没有子数据的不显示展开按钮,有数据才会显示

之前只实现了不显示小箭头,但是后来发现还是可以点击展开,这次更新实现了不显示,且点击无效,在此记录

<el-table
   :data="dataList"  border 
   
	ref="topicTable"
	
    :default-expand-all="false" //所有子菜单是否展开

    :row-class-name="getRowClass">//获取每一行的信息

 	@expand-change="handledetail"//控制是否可以点击展开
</el-table>
//对小箭头做了隐藏
 getRowClass:function(row,rowIndex){
	   console.log(row)
	   console.log(row.row.orderChildEntities)
	   console.log(typeof(row.row.orderChildEntities))
	   if(row.row.orderChildEntities===null){  //判断当前行是否有子数据
	      return 'row-expand-cover'
	    }
 },
 //之前做了隐藏 ,但是还是可以点击展开下级的,加此方法屏蔽点击展开功能
  handledetail(row,expandedRows){
    if(row.orderChildEntities==null){
         this.$refs.topicTable.toggleRowExpansion(row,false)
       }
    },
 <style>
   .row-expand-cover td:first-child .el-icon-arrow-right{visibility: hidden;}
  </style>

刚开始写的时候一直实现不了,总以为是没有精确找到样式位置,后来把style里的scoped属性去掉就好了

  • 9
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值