Vue2:el-table 最后一列的操作按钮不换行,按钮过多时展示【更多】

表格中最后一列为操作按钮。有时候按钮比较多,就会换行展示,将行高撑大,很难看。所以需要控制按钮都显示在同一行,如果太多显示不下,出现一个下拉列表。

1、flex 布局来控制按钮的显示

设置 display: flex 来将按钮放在同一行,设置 white-space: nowrap 来禁止换行。

<el-table-column label="操作">
  <template slot-scope="scope">
    <div style="display: flex; white-space: nowrap;">
      <!-- 这里可以放置操作按钮的代码 -->
    </div>
  </template>
</el-table-column>
 

2、将其它按钮放在el-dropdown 组件中

click触发

<el-table-column label="操作">
  <template slot-scope="scope">
    <div style="display: flex; white-space: nowrap;">
      <el-button>按钮1</el-button>
      <el-button>按钮2</el-button>
      <el-button>按钮3</el-button>
      <el-dropdown trigger="click" style="margin-left: 10px">
        <el-button slot="default" type="text">更多</el-button>
        <el-dropdown-menu slot="default">
          <el-dropdown-item>按钮4</el-dropdown-item>
          <el-dropdown-item>按钮5</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </template>
</el-table-column>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值