element-ui控制表头显示宽度,搭配el-tooltip鼠标移入提示全部表头

el-table表头字数过多隐藏,鼠标移入提示全部文字

表格代码

//表格数据可自行定义
<el-table v-loading="loading" :data="importnodereportList" @selection-change="handleSelectionChange" border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="id" width="150"/>
      <!--重点start-->
      <el-table-column v-for="(item,index) in radios" :key="index" :index="index" :prop="importnodereportList.radioValue" :label="item.dictLabel" align="left" :formatter="radioValueFormat" width="160">
      	<!--主要是用slot="header"搭配tooltip来生成提示内容-->
        <template slot="header" slot-scope="scope">
          <el-tooltip class="item" effect="dark" :content="item.dictLabel" placement="left-start">
            <span>{{item.dictLabel}}</span>
          </el-tooltip>
        </template>
      </el-table-column>
      <!--重点end-->
      <el-table-column label="其他内容" align="center" prop="other" show-overflow-tooltip width="150" />
      <el-table-column label="报备日期" align="center" prop="filingDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.filingDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="节假日" align="center" prop="holiday" :formatter="holidayFormat" />
      <el-table-column label="操作" align="center" class-name="small-padding" width="200">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['discipline:importnodereport:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['discipline:importnodereport:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

css样式代码

//主要用于控制表头宽度,生成省略号
<style lang="scss" scoped>
  /deep/ .cell {
    width: 100%;   /*一定要设置宽度,或者元素内含的百分比*/
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
</style>

js格式化数据

// 格式化有或无按钮
      radioValueFormat(row, column) {
        //写在methods里面,可以拿到行和列的数据,可以根据column.index下标来对行做自己的操作
      },

没改之前

改完之后
鼠标移入有提示,表头展示也统一了

  • [ 可以修改el-tooltip标签属性来修改提示的位置]
element-ui的tooltip文字提示组件
上边top
右边right
下边bottom
左边left
更多位置参数请访问element-ui官方文档
修改el-tooltip提示框宽度,字数过多时可以用到,比如说:好几千字
<style lang="scss">
    .el-tooltip__popper{max-width:80%}
</style>
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值