给el-table表头添加icon图标,以及鼠标移入icon时显示el-tooltip提示内容


 

方法一: 使用element table 提供的slot 属性,设置为header 即可自定义表头内容。代码示例如下:
 
<el-table-column prop="xxx" label="xxx">
  <template slot="header" slot-scope="scope">
    <span>操作{{scope.row.xxx}}</span>
    <i class="icon xxx-icon"/>
  </template>
  <template slot-scope="scope">
    <p>{{scope.row.xxx}}</p>
  </template>
</el-table-column>
 
 
 
方法二:
另外,element table还提供了render-header 属性,也可以对标题进行渲染,

 

代码如下:

methods: { renderHeader(h, { column }) { const serviceContent= [ h( "div", { slot: "content", style: "margin-bottom:5px" }, "内容内容内容内容内容内容内容内容" ), h( "div", { slot: "content" }, "内容内容内容内容内容内容内容呢" ), h( "div", { slot: "content" }, "内容内容内容内容内容内容内容内容" ), h( "div", { slot: "content" }, "内容内容内容内容内容内容内容内容" ), h( "div", { slot: "content", style: "margin-bottom:5px" }, "内容内容内容内容内容内容内容内容内容" ) ]; const paymentContent= h( "div", { slot: "content" }, "内容内容内容" ); return h("div", [ h("span", column.label), h( "el-tooltip", { props: { placement: "bottom" } }, [ column.label != "xx" ? serviceContent: paymentContent, h("i", { class: "el-icon-warning-outline", style: "color:orange;margin-left:5px;" }) ] ) ]); } }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM