vue el-table實現(xiàn)自定義表頭
更新時間:2019年12月11日 15:50:03 作者:*且聽風吟
這篇文章主要為大家詳細介紹了vue el-table實現(xiàn)自定義表頭,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue el-table實現(xiàn)自定義表頭的具體代碼,供大家參考,具體內容如下
el-table可以通過設置 Scoped slot 來實現(xiàn)自定義表頭。
文檔說明如下:
代碼實現(xiàn):
<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>
頁面效果如下:
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
vue?button的@click方法無效鉤子函數沒有執(zhí)行問題
這篇文章主要介紹了vue?button的@click方法無效鉤子函數沒有執(zhí)行問題及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03vue3使用element-plus中el-table組件報錯關鍵字'emitsOptions'與&
這篇文章主要給大家介紹了關于vue3使用element-plus中el-table組件報錯關鍵字'emitsOptions'與'insertBefore'的相關資料,文中將解決方法介紹的非常詳細,需要的朋友可以參考下2022-10-10