给el-table中el-table-column增加控件,图标,运用render-header

@给el-table表头增加控件,图标

前言

element-UI中给el-table表头增加控件,图标,
以及在增加中有增加样式盒子写不上去原因

二、使用步骤

1.组件代码

代码如下(示例):

<el-table-column label="好棒" width="120"  :render-header="render">
</el-table-column>

2.methods中代码

代码如下(示例):

render(h, { column, $index }){
      return h("div", [
         h("span", column.label + "  ", {
        align: "left"
      }),
      h(
        "el-popover",
        {
          props: {
            placement: "top-start",    // 一般 icon 处可添加浮层说明,浮层位置等属性
            width: "300",
            trigger: "hover"
          }
        },
        [
             h("span",{
          style:{
            height: "10px",
            width:"20px",
            background:"#606266",
            display:"inline-block",
             marginRight:"8px"
            
        },
          },),
             h("span",{
          style:{  
             marginRight:"20px"
        },
          },"待执行"),
                h("span",{
          style:{
            height: "10px",
            width:"20px",
            background:"#1ab394",
            display:"inline-block",
             marginRight:"8px"
           },
          },),
             h("span",{
          style:{  
           marginRight:"20px"
        },
          },"已执行"),
                h("span",{
          style:{
            height: "10px",
            width:"20px",
            background:"#f56c6c",
            display:"inline-block",
             marginRight:"8px"    },
          },),
             h("span",{
          style:{  
             marginRight:"20px"
        },
          },"已作废"),
            h("i", {                            // 生成 i 标签 ,添加icon 设置 样式,slot 必填
            class: "el-icon-question",
            slot: "reference"
          })
        ]
      )
  ])
    },

#样式图
在这里插入图片描述


总结

在这里,有一个细节,就是在书写h(“div”,{ style:{width:“100px”}},“123”)时候你要是把123添加到大括号前面,那他的style样式就加不上,要严格这样书写

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Liuzhipeng-hot

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值