欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實現(xiàn)樹狀表格效果

 更新時間:2020年12月29日 16:09:46   作者:保護(hù)我方豆豆  
這篇文章主要為大家詳細(xì)介紹了vue實現(xiàn)樹狀表格效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue實現(xiàn)樹狀表格的具體代碼,供大家參考,具體內(nèi)容如下

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, // 鼠標(biāo)懸停時,是否高亮當(dāng)前行
   showIndex: true, // 是否顯示數(shù)據(jù)索引
   treeType: true, // 是否為樹形表格
   isFold: true, // 樹形表格中父級是否默認(rèn)折疊
   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', // 列標(biāo)題名稱
   prop: 'name', // 對應(yīng)列內(nèi)容的屬性名
   width: '400px', // 列寬度
   },
   {
   label: 'sex',
   prop: 'sex',
   minWidth: '50px',
   },
   {
   label: 'score',
   prop: 'score',
   },
   {
   label: 'likes',
   prop: 'likes',
   minWidth: '200px',
   type: 'template',
   template: 'likes', // 列類型為 'template'(自定義列模板) 時,對應(yīng)的作用域插槽(它可以獲取到 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. 效果

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • webstorm和.vue中es6語法報錯的解決方法

    webstorm和.vue中es6語法報錯的解決方法

    本篇文章主要介紹了webstorm和.vue中es6語法報錯的解決方法,小編總結(jié)了webstorm和.vue中出現(xiàn)的es6語法報錯,避免大家采坑,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Vue報錯:TypeError:Cannot create property 'xxx' on string 'xxxx'問題

    Vue報錯:TypeError:Cannot create property '

    這篇文章主要介紹了Vue報錯:TypeError:Cannot create property 'xxx' on string 'xxxx'問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Vue跑馬燈marquee組件使用方法詳解

    Vue跑馬燈marquee組件使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了Vue跑馬燈marquee組件的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • vue實現(xiàn)導(dǎo)入json解析成動態(tài)el-table樹表格

    vue實現(xiàn)導(dǎo)入json解析成動態(tài)el-table樹表格

    本文主要介紹了vue實現(xiàn)導(dǎo)入json解析成動態(tài)el-table樹表格,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • vue2+springsecurity權(quán)限系統(tǒng)的實現(xiàn)

    vue2+springsecurity權(quán)限系統(tǒng)的實現(xiàn)

    本文主要介紹了vue2+springsecurity權(quán)限系統(tǒng)的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • Vue自定義el-table表格表頭高度的多種實現(xiàn)方法

    Vue自定義el-table表格表頭高度的多種實現(xiàn)方法

    在Vue項目中,使用Element?UI的el-table組件可以輕松創(chuàng)建功能豐富的表格,然而,默認(rèn)情況下,el-table的表頭高度是固定的,本文將詳細(xì)介紹如何自定義el-table表頭的高度,提供多種實現(xiàn)方法,需要的朋友可以參考下
    2024-10-10
  • Vue插槽slot詳細(xì)介紹(對比版本變化,避免踩坑)

    Vue插槽slot詳細(xì)介紹(對比版本變化,避免踩坑)

    Vue中的Slot對于編寫可復(fù)用可擴展的組件是再合適不過了,下面這篇文章主要給大家介紹了關(guān)于Vue插槽slot詳細(xì)介紹的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-06-06
  • 在Vue-cli里應(yīng)用Vuex的state和mutations方法

    在Vue-cli里應(yīng)用Vuex的state和mutations方法

    今天小編就為大家分享一篇在Vue-cli里應(yīng)用Vuex的state和mutations方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • Vuex 單狀態(tài)庫與多模塊狀態(tài)庫詳解

    Vuex 單狀態(tài)庫與多模塊狀態(tài)庫詳解

    這篇文章主要介紹了Vuex 單狀態(tài)庫與多模塊狀態(tài)庫詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • 如何使用elementUI組件實現(xiàn)表格的分頁及搜索功能

    如何使用elementUI組件實現(xiàn)表格的分頁及搜索功能

    最近在使用element-ui的表格組件時,遇到了搜索框功能的實現(xiàn)問題,這篇文章主要給大家介紹了關(guān)于如何使用elementUI組件實現(xiàn)表格的分頁及搜索功能的相關(guān)資料,需要的朋友可以參考下
    2023-03-03

最新評論