极乐门资源网 Design By www.ioogu.com
本文实例为大家分享了vue实现树状表格的具体代码,供大家参考,具体内容如下
1. 初始化配置
安装模块:
npm i vue-table-with-tree-grid -S
main.js 文件
import ZkTable from 'vue-table-with-tree-grid' Vue.component(ZkTable.name, ZkTable);
2. 使用
<template lang="html"> <div id="example"> <zk-table ref="table" index-text="#" :data="data" :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 slot="likes" scope="scope"> {{ scope.row.likes.join(',') }} </template> </zk-table> </div> </template> <script> export default { name: 'example', data() { return { props: { stripe: false, // 是否显示间隔斑马纹 border: true, // 是否显示纵向边框 showHeader: true, // 是否显示表头 showSummary: false, // 是否显示表尾合计行 showRowHover: true, // 鼠标悬停时,是否高亮当前行 showIndex: true, // 是否显示数据索引 treeType: true, // 是否为树形表格 isFold: true, // 树形表格中父级是否默认折叠 expandType: false, // 是否为展开行类型表格(为 True 时,需要添加名称为 '$expand' 的作用域插槽, 它可以获取到 row, rowIndex) selectionType: false, // 是否为多选类型表格 }, data: [ { name: 'Jack', sex: 'male', likes: ['football', 'basketball'], score: 10, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, }, ], }, ], }, ], }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, }, ], }, { name: 'Tom', sex: 'male', likes: ['football', 'basketball'], score: 20, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, }, ], }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, }, ], }, ], }, { name: 'Tom', sex: 'male', likes: ['football', 'basketball'], score: 20, }, { name: 'Tom', sex: 'male', likes: ['football', 'basketball'], score: 20, children: [ { name: 'Ashley', sex: 'female', likes: ['football', 'basketball'], score: 20, }, { name: 'Taki', sex: 'male', likes: ['football', 'basketball'], score: 10, }, ], }, ], columns: [ { label: 'name', // 列标题名称 prop: 'name', // 对应列内容的属性名 width: '400px', // 列宽度 }, { label: 'sex', prop: 'sex', minWidth: '50px', }, { label: 'score', prop: 'score', }, { label: 'likes', prop: 'likes', minWidth: '200px', type: 'template', template: 'likes', // 列类型为 'template'(自定义列模板) 时,对应的作用域插槽(它可以获取到 row, rowIndex, column, columnIndex)名称 }, ], }; }, }; </script> <style scoped lang="less"> * { margin: 0; padding: 0; } .switch-list { margin: 20px 0; list-style: none; overflow: hidden; } .switch-item { margin: 20px; float: left; } </style>
3. 效果
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
标签:
vue,树状表格
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无vue实现树状表格效果的评论...
更新日志
2024年11月15日
2024年11月15日
- 南合文斗.2007-陪君醉笑三千尘鸟人唱片】【FLAC+CUE】
- 群星《我们的歌第六季 第1期》[320K/MP3][90.72MB]
- 群星《我们的歌第六季 第1期》[FLAC/分轨][456.01MB]
- 李雨寰《Break Free》[320K/MP3][98.39MB]
- 草蜢.2001-《真经典》环球唱片[WAV+CUE]
- 群星.2009-第4届2008十大发烧唱片精选[FLAC+CUE]
- 丁红《女儿情》[DTS-WAV]
- 陈惠婷.2017-Voyager3【亚神音乐】【FLAC分轨】
- 群星.2001-华纳歌声魅影【华纳】【WAV+CUE】
- 张雨生.2016-雨后星空2CD【丰华】【WAV+CUE】
- 李雨寰《Break Free》[FLAC/分轨][533MB]
- 廖也欧《面朝大海》[320K/MP3][18.35MB]
- 廖也欧《面朝大海》[Hi-Res][24bit 48kHz][FLAC/分轨][170.14MB]
- s13T1夺冠五人名单都有谁 s13T1夺冠五人名单一览
- 英雄联盟T1战队队长都有谁 T1战队所有队长介绍