21.element el-table表格以及树形表格封装

21.element el-table表格以及树形表格封装

1.效果图

  • 树形表格效果图
    在这里插入图片描述
  • 普通表格效果图
    在这里插入图片描述

2.表格组件

组件名称:YpTable.vue
组件内容:当然有其他的需要加的可以自行添加一些其他类型


<template>
  <el-table :data="list" stripe border :default-expand-all="expand" row-key="id" :tree-props="{ children: children }">
    <!-- 循环表格标签以及类型 -->
    <el-row v-for="(item, index) in propArr" :key="index">
      <!-- 当父组件的type值等于'img'表示此列显示图片 -->
      <el-table-column v-if="item.type === 'img'" :prop="item.props" :label="item.label" align="center">
        <template slot-scope="scope">
          <img style="width:50px;height:50px" :src="scope.row[props]" alt="" />
        </template>
      </el-table-column>
      <!-- 当父组件的type值等于'icon'表示此列显示图标 -->
      <el-table-column v-else-if="item.type === 'icon'" :prop="item.props" :label="item.label" align="center">
        <template slot-scope="scope">
          <i :class="scope.row[item.props]"></i>
        </template>
      </el-table-column>
      <!-- 当父组件的type值等于'select'表示此列显示checkbox -->
      <el-table-column v-else-if="item.type === 'select'" type="selection" width="50"> </el-table-column>
      <!-- 当父组件的type值等于'switch'表示此列显示开关 -->
      <el-table-column v-else-if="item.type === 'switch'" :prop="item.props" :label="item.label" align="center">
        <template slot-scope="scope">
          <el-switch v-model="scope.row[item.props]" @change="servicePublishChange(scope.row)"> </el-switch>
        </template>
      </el-table-column>
      &
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值