vue-table-with-tree-grid的使用

vue-table-with-tree-grid的使用

// 1. 引入vue-table-with-tree-grid
import ZkTable from 'vue-table-with-tree-grid'
Vue.component(ZkTable.name, ZkTable)


// 2. 在在组件中写入
<zk-table
        :data="tableData"
        show-index
        index-text="#"
        border
        :columns="columns"
        children-prop="children"
        :show-row-hover="false"
        :selection-type="false"
        :expand-type="false"
      >
        
      </zk-table>

// 3. 在data中配置columnsw 把内容渲染出来
columns: [
        {
          label: "分类名称",
          prop: "cat_name",
        },
        {
        //表格名称
          label: "是否有效",
          //本列表格数据
          prop: "cat_deleted",
          //定义插槽
          type: "template",
          //插槽名
          template: "scoped",
        },
        {
          label: "排序",
          prop: "cat_level",
          type: "template",
          template: "spoe",
        },
        {
          label: "操作",
          type: "template",
          template: "solt",
        },
      ],


// 4. 在zk-table中写入

<template slot="scoped" scope="scope">
          <i
            class="el-icon-success"
            style="color: green; width: 20px; height: 20px"
            v-if="scope.row.cat_deleted == true"
          ></i>
          <i
            class="el-icon-error"
            style="color: red; width: 20px; height: 20px"
            v-if="scope.row.cat_deleted == false"
          ></i>
        </template>
        <template slot="spoe" scope="scope">
          <el-tag :type="types[scope.row.cat_level]">{{
            (scope.row.cat_level + "") | dengji
          }}</el-tag>
        </template>
        <template slot="solt" scope="scope">
          <div class="scodv">
            <el-button type="primary" class="el-but" @click="compild(scope.row)"
              ><i class="el-icon-edit">编辑</i></el-button
            >
            <el-button type="danger" class="el-but" @click="remove(scope.row)"
              ><i class="el-icon-delete">删除</i></el-button
            >
          </div>
        </template>


在data中定义

      columns: [
        {
          label: "分类名称",
          prop: "cat_name",
        },
        {
          label: "是否有效",
          prop: "cat_deleted",
          type: "template",
          template: "likes",
        },
        {
          label: "排序",
          prop: "cat_level",
          type: "template",
          template: "isrt",
        },
        {
          label: "操作",
          type: "template",
          template: "isort",
        },
      ],
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值