vue el-table實現(xiàn)自定義表頭
更新時間:2019年12月11日 15:50:03 作者:*且聽風(fēng)吟
這篇文章主要為大家詳細(xì)介紹了vue el-table實現(xiàn)自定義表頭,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue el-table實現(xiàn)自定義表頭的具體代碼,供大家參考,具體內(nèi)容如下
el-table可以通過設(shè)置 Scoped slot 來實現(xiàn)自定義表頭。
文檔說明如下:

代碼實現(xiàn):
<template>
<el-dialog
width="50%"
:visible.sync="isShow"
:before-close="beforeClose"
title="自定義設(shè)備類型屬性">
<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>
頁面效果如下:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue路由跳轉(zhuǎn)傳參或打開新頁面跳轉(zhuǎn)的方法總結(jié)
這篇文章主要給大家介紹了關(guān)于Vue路由跳轉(zhuǎn)傳參或打開新頁面跳轉(zhuǎn)的相關(guān)資料,在使用Vue.js開發(fā)單頁面應(yīng)用時常常會遇到路由跳轉(zhuǎn)傳參的需求,需要的朋友可以參考下2023-07-07
解決vue-photo-preview 異步圖片放大失效的問題
這篇文章主要介紹了解決vue-photo-preview 異步圖片放大失效的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07
echarts 使用formatter 修改鼠標(biāo)懸浮事件信息操作
這篇文章主要介紹了echarts 使用formatter 修改鼠標(biāo)懸浮事件信息操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07
vue?axios?form-data格式傳輸數(shù)據(jù)和文件方式
這篇文章主要介紹了vue?axios?form-data格式傳輸數(shù)據(jù)和文件方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-05-05

