登录
首页 >  文章 >  前端

Element Table 表头文字对齐:如何实现不同长度的表头文字对齐?

时间:2024-12-08 08:07:04 142浏览 收藏

推广推荐
免费电影APP ➜
支持 PC / 移动端,安全直达

今天golang学习网给大家带来了《Element Table 表头文字对齐:如何实现不同长度的表头文字对齐?》,其中涉及到的知识点包括等等,无论你是小白还是老手,都适合看一看哦~有好的建议也欢迎大家在评论留言,若是看完有所收获,也希望大家能多多点赞支持呀!一起加油学习~

Element Table 表头文字对齐:如何实现不同长度的表头文字对齐?

element table 表头文字对齐疑难

如何在 element table 中将不同长度的表头文字对齐,如两个字与四个字?

传统的通过给 label 属性添加空格的方法并不奏效。对此,推荐使用以下解决方案:

自定义表头

利用 slot-scope 插槽,自定义表头内容,实现对齐:

<el-table-column
  :label=&quot;'自定义表头'&quot;
  width=&quot;45&quot;
  v-show=&quot;item.children.length&quot;
  v-for=&quot;(citem, cindex) in item.children&quot;
  :key=&quot;cindex&quot;
  align=&quot;center&quot;
>
  <template slot-scope=&quot;scope&quot;&gt;
    {{ scope.row.dataList[citem.index].count }}
  </template>
  <template slot=&quot;header&quot;&gt;
    <div  v-html=&quot;citem.name&quot;&gt;&lt;/div&gt;
  </template>
</el-table-column>

通过自定义表头,利用 v-html 输出 citem.name 可以实现对齐需求。

文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《Element Table 表头文字对齐:如何实现不同长度的表头文字对齐?》文章吧,也可关注golang学习网公众号了解相关技术文章。

相关阅读
更多>
最新阅读
更多>
课程推荐
更多>