vue+element table的二次封装
  • 作者:admin
  • 发表时间:2020-11-18 07:50
  • 来源:未知

table.vue文件

<el-table< p="">

<pre class="wp-block-code" style="box-sizing: border-box; font-size: 13px; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; word-spacing: 0px; text-transform: none; word-break: break-all; font-weight: 300; color: #333333; font-style: normal; orphans: 2; widows: 2; margin: 0px 0px 10px; display: block; letter-spacing: normal; line-height: 1.4285; background-color: #f5f5f5; text-indent: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; overflow-wrap: break-word; border-radius: 0px; border: #cccccc 1px solid; padding: 9px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; white-space: pre-wrap; margin: 0px 5px; background-color: transparent; border-radius: 0px; border: #e1e1e1 1px solid; padding: 0px;"><template> <el-table :data="tableData" style="width: 100%" :row-class-name="tableRowClassName" :cell-style="{textAlign:'center'}" @selection-change="change" :show-heade唐山快速排名r="showHeader" :border="border" :max-height="maxHeight" :v-loading="loading" :class="className" element-loading-text="给我一点时间" stripe fit highlight-current-row > <template v-for="tableColumn in tableList"> <el-table-column :type="tableColumn.type" :width="tableColumn.width" v-if="tableColumn.type === 'selection'" ></el-table-column> <!-- slot 添加自定义配置项--> <slot v-if="tableColumn.slot" :name="tableColumn.slot" ></slot> <!-- component 特殊处理某一项--> <component v-else-if="tableColumn.component" :is="config.component" :col-config="tableColumn" ></component> <el-table-column :label="tableColumn.label" :type="tableColumn.type" :prop="tableColumn.prop" :width="tableColumn.width" :fixed="tableColumn.fixed " :sortable="tableColumn.sortable" v-if="(tableColumn.type !== 'selection')&&(tableColumn.type !== 'slot')" > </el-table-column> </template> </el-table> </template> <script> export default { data(){ return{} }, props: { tableList: { type: Array, default: function() { return []; } }, tableData: { type: Array, default: function() { return []; } }, showHeader: { type: Boolean, default: true }, border: { type: Boolean, default: false }, maxHeight: { type: [String, Number], default: null }, loading: { type: Boolean, default: false }, className: { type: String, default: "" }, tableRowClassName: { type: String, default: "" } } } </script> <style scoped> </style></code></pre>