本文实例为大家分享了vue el-table实现自定义表头的具体代码,供大家参考,具体内容如下
el-table可以通过设置 scoped slot 来实现自定义表头。
文档说明如下:
代码实现:
<template> <el-dialog width="50%" :visible.sync="isshow" :before-close="beforeclose" title="自定义设备类型属性"> <div class="dialogdiv"> <el-table :data="tabledata.filter(data => handleadd || data.name.tolowercase().includes(handleadd.tolowercase()))" style="width: 100%" border> <el-table-column prop="code" :label="$t('basicdata.device.propdlg.code')"> </el-table-column> <el-table-column prop="maxvalue" :label="$t('basicdata.device.propdlg.maxvalue')"> </el-table-column> <el-table-column prop="minvalue" :label="$t('basicdata.device.propdlg.minvalue')"> </el-table-column> <el-table-column prop="name" :label="$t('basicdata.device.propdlg.name')"> </el-table-column> <el-table-column prop="valuetype" :label="$t('basicdata.device.propdlg.valuetype')"> </el-table-column> <el-table-column prop="warning" :label="$t('basicdata.device.propdlg.warning')"> </el-table-column> <el-table-column align="center" width="160px"> <template slot="header" slot-scope="scope"> <el-button v-model="handleadd" size="mini" type="success" circle plain icon="el-icon-plus" @click="handleadd(scope.$index, scope.row)"> </el-button> </template> <template slot-scope="scope"> <el-button size="mini" type="primary" circle plain icon="el-icon-edit" @click="handleedit(scope.$index, scope.row)"> </el-button> <el-button size="mini" type="danger" circle plain icon="el-icon-delete" @click="handledelete(scope.$index, scope.row)"> </el-button> </template> </el-table-column> </el-table> </div> <span slot="footer"> <el-button @click="cancel">{{ $t('common.cancel') }}</el-button> <el-button @click="confirm" type="primary">{{ $t('common.confirm') }}</el-button> </span> </el-dialog> </template> <script> export default { data() { return { tabledata: [] } }, methods: { // 添加 handleadd() { }, // 编辑 handleedit(index, row) { }, // 删除 handledelete(index, row) { }, cancel() { this.$emit("cancel") }, confirm() { this.$emit("confirm", this.tabledata) } } }; </script> <style lang="scss" scoped> .dialogdiv { height: 300px; overflow: auto; } </style>
页面效果如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
CTF 刷题记录(一) 白云新闻搜索(手动与自动化SQL注入)
javascript如何使用函数random来实现课堂随机点名方法详解
网友评论