码迷,mamicode.com
首页 > 其他好文 > 详细

vue树形三级分层控件的使用

时间:2020-06-17 23:30:23      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:head   span   success   att   OWIN   安装   sum   key   vue   

渲染出来之后就是这个样子了

技术图片

 

1. 使用的话是借用一个vue依赖   ===>   vue-table-with-tree-grid   <=== 在依赖中安装

2. 在项目的main.js文件中引入并且注册为全局组件

// 引入树形控件
import ZkTable from vue-table-with-tree-grid

Vue.component(tree-table, ZkTable)

3. 具体使用,建议把官网的demo复制粘贴过去,然后根据需求改, 因为本人在使用的时候, 因为是需要什么功能, 在tree-table 中添加什么attribute , 所以总是报错 , 说什么key值不唯一, 反正就是组件渲染出错, 然后把官方demo中的代码复制过去, 修改, 就没有出现问题

<tree-table
        ref="table"
        sum-text="sum"
        index-text="#"
        :data="cateList"
        :columns="columns"
        :stripe="props.stripe"
        :border="props.border"
        :show-header="props.showHeader"
        :show-summary="props.showSummary"
        :show-row-hover="props.showRowHover"
        :show-index="props.showIndex"
        :tree-type="props.treeType"
        :is-fold="props.isFold"
        :expand-type="props.expandType"
        :selection-type="props.selectionType"
      >
// 这里写模板 template , 和columns中的魔板名字相同 </ tree-table>

    
columns: [{
          label: ‘是否有效‘,
          type: ‘template‘,
          template: ‘userful‘,
          width: 100
        }]

在template中使用  slot="name"  指定模板的名字 , 使用 slot-scope="scope" 指定数据源 , 通过 scope.row  拿到当前的数据

<!-- 排序模板 -->
        <template slot="sort" slot-scope="scope">
          <el-tag v-if="scope.row.cat_level === 0">一级</el-tag>
          <el-tag v-else-if="scope.row.cat_level === 1" type="success">二级</el-tag>
          <el-tag v-else type="warning">三级</el-tag>
        </template>

 

Attribute不晓得少了哪个, 反正一直报错 

技术图片

直接管他默认的是啥, cv过去, 就没有报错了

 

vue树形三级分层控件的使用

标签:head   span   success   att   OWIN   安装   sum   key   vue   

原文地址:https://www.cnblogs.com/liuyuexue520/p/13155017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!