饿了么表格二次封装具名插槽append的分装实现
1)在封装组件中使用table具名插槽,并自定义具名插槽,对外开发使用:commonTable
<template> <div class="common-table-style"> <el-table :data="tableData" tooltip-effect="dark" border highlight-current-row :max-height="maxHeight" :empty-text="emptyText" @sort-change="sortChange" @filter-change="filterChange" @selection-change="selectionChange" ref="commonRef" > <slot></slot> <div slot="append"> <slot name="xxxx"></slot> </div> </el-table> </div> </template> <script> export default { props: { tableData: { type: Array, default: () => {} }, maxHeight: { type: Number, default: null }, emptyText: { type: String, default: "暂无数据" } }, methods: { sortChange(e) { this.$emit("sortChange", e); }, filterChange(e) { this.$emit("filterChange", e); }, selectionChange(e) { this.$emit("selectionChange", e); } } }; </script> 2)封装组件的使用方法: <template> <div v-loading="loading"> <sn-table :tableData="entityTableData.list" class="mt20"> <el-table-column label="名称" prop="name" show-overflow-tooltip></el-table-column> <el-table-column label="中文名" prop="entityChName" show-overflow-tooltip></el-table-column> <div slot="xxxxx"> more content </div> </sn-table> </div> </template>
相关推荐
Roka 2020-06-28
xhpscdx 2020-05-17
chaigang 2020-02-25
歆萌 2020-02-02
chunianyo 2019-12-21
疯狂紫萧 2019-12-14
PHP淮北PHP00网 2013-09-17
歆萌 2019-11-03
Kwong 2019-10-22
宇智波鼬 2018-08-30
zhrookie 2011-11-18
81423067 2015-06-02
wewoor 2015-12-27
lizaochengwen 2019-03-19
stSahana 2016-11-01
yangno 2017-03-23