您的位置:首页 > Web前端 > Vue.js

vue element + Table表格表头样式设置

2020-06-24 04:29 225 查看

通过设置 :header-cell-style="{backgroundColor:’#fcfcfc’}"
设置每一行内容超出隐藏 :show-overflow-tooltip=“true”
设置每一行内容居中 align=“center”
第一种:

<template>
<div>
<el-table :data="tableData" :header-cell-style="{backgroundColor:'#fcfcfc', color: '#333'}">
<el-table-column prop="name" label="姓名" width="150" align="center" :show-overflow-tooltip="true">
</el-table-column>
...
</el-table>
</div>
</template>

第二种:

<template>
<div>
<el-table :data="tableData" :header-cell-style="tabHeader" >
<el-table-column prop="name" label="姓名" width="150" align="center" :show-overflow-tooltip="true">
</el-table-column>
...
</el-table>
</div>
</template>

<script>
export default {
methods: {
tabHeader() {
return 'backgroundColor:#3f4160;color:#fff'
}
}
}

第三种:
在utils下的 tool.js中封装一个表格表头函数

//util文件夹下的tool.js
// 表格头部
export const tabHeader = function () {
return 'backgroundColor:#1f8e88;color:#fff;text-align:center;height:40px;padding:0;'
}
<template>
<div>
<el-table :data="tableData" style="width: 100%" :header-cell-style="tabHeader">
<el-table-column prop="name" label="姓名" width="150" align="center" :show-overflow-tooltip="true">
</el-table-column>
...
</el-table>
</div>
</template>
<script>
import { tabHeader } from '@/utils/tool'
export default {
data() {
return {
tabHeader: tabHeader,
},
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐