关于el-table的组件使用
作者:互联网
子组件myTable
<template>
<el-table
:data="tableData"
size="small"
border
:cell-style="cellStyle"
:header-cell-style="headerStyle"
class="table"
:max-height="tableHeight"
@selection-change="handleSelection"
>
<el-table-column v-if="showSelection" type="selection" />
<el-table-column v-for="item in columnList" :key="item.prop" :label="item.label" :prop="item.prop" :formatter="item.formatter?item.formatter: null" />
<slot />
</el-table>
</template>
<script>
import constants from '~/plugins/constants'
export default {
name: 'MyTable',
props: {
tableData: {
type: Array,
default: () => []
},
showSelection: {
type: Boolean,
default: false
},
columnList: {
type: Array,
default: () => []
}
},
data () {
return {
tableHeight: 0
}
},
mounted () {
this.$nextTick(() => {
this.tableHeight = constants.METHOD.setTableHeight()
})
},
methods: {
cellStyle () {
return {
textAlign: 'center'
}
},
headerStyle () {
return {
textAlign: 'center',
backGroundColor: 'red'
}
},
handleSelection (val) {
this.$emit('handleSelection', val)
}
}
}
</script>
<style scoped>
</style>
标签:el,return,val,default,组件,table,type,textAlign,constants 来源: https://blog.csdn.net/m0_45868673/article/details/120186420