Element el-table el-table-column 表头自定义

18 篇文章 0 订阅
8 篇文章 0 订阅

在这里插入图片描述

     <el-table
          :data="datas"
          stripe
          style="width: 100%;"
      >
          <el-table-column fixed type="index" label="序号" width="50" style="text-align: center"> </el-table-column>
          <el-table-column
              prop="client_name"
              label="客户"
              fixed
              width="80">
          </el-table-column>
          <el-table-column
              prop="style_no"
              label="款号-订单号-部门号"
              width="150">
          </el-table-column>
          <el-table-column label="订单性质" width="80">
              <template slot-scope="scope">
                  <el-tag v-if="scope.row.order_type == 0" type="info">${ scope.row.ordertype }</el-tag>
                  <el-tag v-else-if="scope.row.order_type == 1" type="success">${ scope.row.ordertype }</el-tag>
                  <el-tag v-else-if="scope.row.order_type == 2" type="warning">${ scope.row.ordertype }</el-tag>
                  <el-tag v-else-if="scope.row.order_type == 3" type="warning">${ scope.row.ordertype }</el-tag>
                  <el-tag v-else-if="scope.row.order_type == 4" type="danger">${ scope.row.ordertype }</el-tag>
              </template>
          </el-table-column>

          <el-table-column
              prop="tod_date"
              label="出货日期" width="100">
          </el-table-column>
          <el-table-column
              label="国别"
              width="450">
              <template slot="header" slot-scope="scope">
                  <span>国别</span>
                  <span style="color:#000000">(海运/</span>
                  <span style="color:#CC0000;">空运</span>
                  <span style="color:#000000">/</span>
                  <span style="color:#FF00FF;">铁路</span>
                  <span style="color:#000000">/</span>
                  <span style="color:#0000FF;">海空</span>
                  <span style="color:#000000"></span>
              </template>
              <template slot-scope="scope">
                  <template v-for="tag in scope.row.nations">
                      <template v-if="tag.flag == 0">
                          <el-tag :key="tag.value" title="海运">
                              <span style="color: #000000"> ${tag.name} </span>
                          </el-tag>
                      </template>
                      <template v-else-if="tag.flag == 1" title="空运">
                          <el-tag :key="tag.value" type="success">
                              <span style="color: #CC0000"> ${tag.name} </span>
                          </el-tag>
                      </template>
                      <template v-else-if="tag.flag == 2" title="陆运铁路">
                          <el-tag :key="tag.value" type="warning">
                              <span style="color: #FF00FF"> ${tag.name} </span>
                          </el-tag>
                      </template>
                      <template v-else-if="tag.flag == 3" title="海空">
                          <el-tag :key="tag.value" type="danger">
                              <span style="color: #0000FF"> ${tag.name} </span>
                          </el-tag>
                      </template>
                  </template>
              </template>
          </el-table-column>
          </el-table>

在这里插入图片描述

<el-table-column width="180">
    <template slot="header" slot-scope="scope">
      销售提成
      <el-tooltip effect="dark" content="若销售提成按“百分比”,则根据“活动价”来计算" placement="top">
        <i class="el-icon-info"></i>
      </el-tooltip>
    </template>
    <template slot-scope="scope">
      ...
    </template>
</el-table-column>

在这里插入图片描述

<el-table-column
  prop="address"
  :render-header="renderTableHeader">
</el-table-column>
 methods:{
	renderTableHeader (h, { column, $index }) {
		 return h('div', {}, [
		   h('el-popover', {
		     ref: 'popover1',
		     props: {
		       placement: 'top-start',
		       title: '标题',
		       width: '200',
		       trigger: 'hover',
		       content: '这是一段内容,这是一段内容,这是一段内容,这是一段内容。'
		     }
		   }),
		   h('span', {}, [
		     '地址',
		     h('i', {
		       'class': 'el-icon-question',
		       // 自定义指令
		       directives: [
		         {
		           name: 'popover',
		           arg: 'popover1'
		         }
		       ]
		     })
		   ])
		 ])
	}
}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Element Plus 的 el-table-v2 组件支持自定义多级表头,可以通过 el-table-column 的 children 属性来实现。具体步骤如下: 1. 在 el-table-column 中设置 prop 和 label 属性,用于显示表头名称和对应的数据字段。 2. 如果需要设置多级表头,可以在 el-table-column 中设置 children 属性,并在其中嵌套新的 el-table-column 组件,重复步骤1。 3. 如果需要合并表头单元格,可以在 el-table-column 中设置 rowspan 和 colspan 属性。 4. 如果需要自定义表头样式,可以在 el-table-column 中设置 headerStyle 属性。 下面是一个示例代码,展示了如何使用 el-table-v2 自定义多级表头: ``` <template> <el-table :data="tableData"> <el-table-column prop="name" label="姓名"></el-table-column> <el-table-column label="成绩"> <el-table-column prop="math" label="数学"></el-table-column> <el-table-column prop="english" label="英语"></el-table-column> <el-table-column prop="chinese" label="语文"></el-table-column> </el-table-column> <el-table-column prop="total" label="总分" rowspan="2"></el-table-column> </el-table> </template> <script> import { ref } from "vue"; import { ElTable, ElTableColumn } from "element-plus"; export default { components: { ElTable, ElTableColumn, }, setup() { const tableData = ref([ { name: "张三", math: 80, english: 90, chinese: 85, total: 255 }, { name: "李四", math: 75, english: 85, chinese: 90, total: 250 }, ]); return { tableData, }; }, }; </script> ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值