elementUI之table组件封装

在这里插入图片描述


背景

今天带来的是UI库中的table 组件封装;背景toB开发需求中大量的使用table组件,导致代码结构层次上非常冗余,功能点也经常重复的书写;为了不做重复造轮子的工作,秉承高可用高复用的开发效率,对此进行封装

案例展示

此案例仅展示简单封装,仅供学习参考,具体需要根据自己的项目来做更加复杂的功能封装

如需使用请移至更新篇
源码:https://github.com/Dawn-ferry/vue-ele-ui.git

    <hr />
    <SimpleTable
      ref="multipleTable"
      :tableData="tableData"
      :filterColums="filterColums"
      selectType="selection"
      @handleSelect="handleSelect"
    >
      <template v-slot:tableBody="{ scopeData: { row, column } }">
        <template v-if="column.property === 'enable'">
          <div v-if="row.enable === 0" style="color: #d9001b">禁用</div>
          <div v-else style="color: #67c23a">启用</div>
        </template>
        <template v-else-if="column.property === 'imgCover'">
          <img v-if="row.imgCover" :src="row.imgCover" style="width: 80px; height: 80px" />
        </template>
        <template v-else-if="column.property === 'effectiveDate'"> {
   {
    row.date }}~{
   {
    row.endDate }} </template>
        <template v-else-if="column.property === 'edit'">
          <el-button type="text" size="small" @click="openFn(row)">查看</el-button>
          <el-button type="text" size="small" @click="editFn(row)">编辑</el-button>
        
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值