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

vxe-table中vxe-grid的使用解讀

 更新時間:2023年10月16日 15:18:26   作者:鳴拙  
這篇文章主要介紹了vxe-table中vxe-grid的使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

vxe-grid的使用

渲染表格的話,不可能所有的數(shù)據(jù)都是靠自己手動生成的,需要通過v-for渲染出來,

v-for循環(huán)生成列

<template>
  <div>
    <vxe-table
          border="inner"
          highlight-hover-row
          highlight-current-row
          ref="xTable"
          height="300"
          :data="tableData">
          <vxe-table-column v-for="(config, index) in tableColumn" :key="index" v-bind="config"></vxe-table-column>
        </vxe-table>
  </div>
</template>
<script>
export default {
  data () {
    return {
      allAlign: null,
      tableColumn: [
        { type: 'seq', width: 60, fixed: null },
        { type: 'checkbox', width: 50, fixed: null },
        { field: 'name', title: 'Name', width: 200 },
        { field: 'nickname', title: 'Nickname', width: 300 },
        { field: 'sex', title: 'Sex', width: 200 },
        { field: 'role', title: 'Role', width: 200 },
        { field: 'address', title: 'Address', width: 300, showOverflow: true }
      ],
      tableData: [
        { id: 10001, name: 'Test1', nickname: 'T1', role: 'Develop', sex: 'Man', age: 28, address: 'vxe-table 從入門到放棄' },
        { id: 10002, name: 'Test2', nickname: 'T2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
        { id: 10003, name: 'Test3', nickname: 'T3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
        { id: 10004, name: 'Test4', nickname: 'T4', role: 'Designer', sex: 'Women ', age: 23, address: 'vxe-table 從入門到放棄' },
        { id: 10005, name: 'Test5', nickname: 'T5', role: 'Develop', sex: 'Women ', age: 30, address: 'Shanghai' },
        { id: 10006, name: 'Test6', nickname: 'T6', role: 'Designer', sex: 'Women ', age: 21, address: 'vxe-table 從入門到放棄' },
        { id: 10007, name: 'Test7', nickname: 'T7', role: 'Test', sex: 'Man ', age: 29, address: 'vxe-table 從入門到放棄' },
        { id: 10008, name: 'Test8', nickname: 'T8', role: 'Develop', sex: 'Man ', age: 35, address: 'vxe-table 從入門到放棄' }
      ]
    }
  }
}
</script>

如果是從后端獲取數(shù)據(jù)的話,推薦使用vxe-grid來渲染表格

vxe-grid生成表格

<template>
  <div>
    <vxe-grid
      border
      resizable
      show-footer
      ref="xGrid"
      :footer-method="footerMethod"
      height="400"
      :tree-config="{lazy: true, children: 'children', hasChild: 'hasChild', loadMethod: loadChildrenMethod}"
      :edit-config="{ trigger: 'click', mode: 'row', showStatus: true }"
      :columns="columns"
      :data="data"
    ></vxe-grid>
  </div>
</template>

<script>
export default {
  data () {
    return {
      columns: [
        { type: 'seq', width: 60, fixed: 'left' },
        // { type: 'checkbox', title: 'ID', width: 140, fixed: 'left', treeNode: true },
        // eslint-disable-next-line no-undef
        { field: 'name', title: 'Name', editRender: { name: 'NameCon', event }, treeNode: true },
        { field: 'nickname', title: 'Nickname' },
        {
          field: 'role',
          title: 'Role',
          type: 'text',
          cellRender: { name: 'input' }
        },
        {
          field: 'sex',
          title: 'Sex',
          cellRender: { name: 'DICT', props: { code: 'SEX_LIST' } }
        },
        { field: 'describe', title: 'Describe', showOverflow: true }
      ],
      data: []
    }
  },
  created () {
    this.findList()
  },
  methods: {
    changeData () {
      const xTable = this.$refs.xGrid.tableData
      console.log(xTable)
      for (let i = 0; i < xTable.length; i++) {
        // xTable[i].name = '{"name":"aaaaa"}'
        xTable[i].name = 'name1'
        if (xTable[i].children && xTable[i].children.length) {
          for (let j = 0; j < xTable[i].children.length; j++) {
            // xTable[i].children[j].name = '{"name":"bbbb"}'
            xTable[i].children[j].name = 'bbb'
            // xTable[i].children[j] = []
          }
          // xTable[i].children = []
        }
      }
      // this.$refs.xGrid.clearTreeExpand()
      // this.$refs.xGrid.setTreeExpand(xTable[0], true)
      console.log(xTable)
    },
    footerMethod () {
      console.log(1212)
      return this.footerData
    },
    findList () {
      // const _this = this
      this.data = [
        {
          //         // name: 'name1',
          name: '{"name":"children"}',
          nickname: 'T1',
          role: '前端',
          sex: '1',
          age: 22,
          status: '1',
          describe: 'Address abc123',
          hasChild: true
        },
        {
          name: '{"name":"children"}',
          // name: 'name-children',
          nickname: 'Test1-1',
          role: '去掉',
          sex: '22',
          age: '0',
          status: '2',
          describe: 'Address rttry',
          hasChild: false
        },
        {
          name: '{"name":"children"}',
          // name: 'name-children',
          nickname: 'Test1-2',
          role: '測試',
          sex: '1',
          age: '26',
          status: '3',
          describe: 'Address xxxxx',
          hasChild: true
        }
      ]
      const allColumn = this.columns
      console.log(this.data)
      this.footerData = [
        allColumn.map((column, columnIndex) => {
          if (columnIndex === 0) {
            return '平均'
          }
          return columnIndex
        }),
        allColumn.map((column, columnIndex) => {
          if (columnIndex === 0) {
            return '和值'
          }
          return columnIndex
        })
      ]
    },
    loadChildrenMethod ({ row }) {
      // 模擬后臺
      return new Promise(resolve => {
        setTimeout(() => {
          const childs = [
            { name: 'name-children', nickname: 'Test1-1', role: '去掉', sex: '22', age: '0', status: '2', describe: 'Address rttry' },
            { name: 'name-children', nickname: 'Test1-2', role: '測試', sex: '1', age: 26, status: '3', describe: 'Address xxxxx' }
          ]
          const rowChildren = {
            name: row.name, nickname: row.nickname, role: row.role, sex: row.sex, age: row.age
          }
          childs.push(rowChildren)
          resolve(childs)
        }, 300)
      })
    },
    linkEvent ({ row }) {
      console.log(row.name)
    }
  }
}
</script>
<style>
.progress {
  height: 10px;
  background: #ebebeb;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  border-radius: 10px;
}
.progress > span {
  position: relative;
  float: left;
  margin: 0 -1px;
  min-width: 30px;
  height: 10px;
  line-height: 16px;
  text-align: right;
  background: #cccccc;
  border: 1px solid;
  border-color: #bfbfbf #b3b3b3 #9e9e9e;
  border-radius: 10px;
  background-image: -webkit-linear-gradient(
    top,
    #f0f0f0 0%,
    #dbdbdb 70%,
    #cccccc 100%
  );
  background-image: -moz-linear-gradient(
    top,
    #f0f0f0 0%,
    #dbdbdb 70%,
    #cccccc 100%
  );
  background-image: -o-linear-gradient(
    top,
    #f0f0f0 0%,
    #dbdbdb 70%,
    #cccccc 100%
  );
  background-image: linear-gradient(
    to bottom,
    #f0f0f0 0%,
    #dbdbdb 70%,
    #cccccc 100%
  );
  -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}
.progress .orange {
  background: #fe8e01;
  border-color: #fe8e02 #fe8e02 #bf6b02;
  background-image: -webkit-linear-gradient(
    top,
    #feaa41 0%,
    #fe8e02 70%,
    #fe8e01 100%
  );
  background-image: -moz-linear-gradient(
    top,
    #feaa41 0%,
    #fe8e02 70%,
    #fe8e01 100%
  );
  background-image: -o-linear-gradient(
    top,
    #feaa41 0%,
    #fe8e02 70%,
    #fe8e01 100%
  );
  background-image: linear-gradient(
    to bottom,
    #feaa41 0%,
    #fe8e02 70%,
    #fe8e01 100%
  );
}
</style>

在這里插入圖片描述

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue如何點(diǎn)擊多個tab標(biāo)簽打開關(guān)閉多個頁面

    vue如何點(diǎn)擊多個tab標(biāo)簽打開關(guān)閉多個頁面

    這篇文章主要介紹了vue如何點(diǎn)擊多個tab標(biāo)簽打開關(guān)閉多個頁面,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • VUE3中Element table表頭動態(tài)展示合計信息

    VUE3中Element table表頭動態(tài)展示合計信息

    本文主要介紹了在Vue中實(shí)現(xiàn)動態(tài)合計兩個字段并輸出摘要信息的方法,通過使用監(jiān)聽器和深度監(jiān)聽,確保當(dāng)數(shù)據(jù)變化時能正確更新合計結(jié)果,具有一定的參考價值,感興趣的可以了解一下
    2024-11-11
  • Vue.js中的高級面試題及答案

    Vue.js中的高級面試題及答案

    Vue-loader 是 Webpack 的加載模塊,它使我們可以用 Vue 文件格式編寫單文件組件。這篇文章主要介紹了Vue.js的高級面試題以及答案,需要的朋友可以參考下
    2020-01-01
  • vue v-model動態(tài)生成詳解

    vue v-model動態(tài)生成詳解

    本篇文章給大家分享了vue v-model動態(tài)生成的相關(guān)知識點(diǎn)以及實(shí)例代碼,有興趣的朋友參考學(xué)習(xí)下。
    2018-06-06
  • vue?elementUI之this.$confirm的使用方式

    vue?elementUI之this.$confirm的使用方式

    這篇文章主要介紹了vue?elementUI之this.$confirm的使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • vue項目總結(jié)之文件夾結(jié)構(gòu)配置詳解

    vue項目總結(jié)之文件夾結(jié)構(gòu)配置詳解

    這篇文章主要給大家總結(jié)介紹了關(guān)于vue項目之文件夾結(jié)構(gòu)配置的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-12-12
  • 一文帶你詳細(xì)了解vue axios的封裝

    一文帶你詳細(xì)了解vue axios的封裝

    對請求的封裝在實(shí)際項目中是十分必要的,它可以讓我們統(tǒng)一處理 http 請求,比如做一些攔截,處理一些錯誤等,本篇文章將詳細(xì)介紹如何封裝 axios 請求,需要的朋友可以參考下
    2023-09-09
  • Vue.prototype詳解及使用方式

    Vue.prototype詳解及使用方式

    這篇文章主要介紹了Vue.prototype詳解及使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • vue如何監(jiān)聽el-select選擇值的變化

    vue如何監(jiān)聽el-select選擇值的變化

    這篇文章主要介紹了vue如何監(jiān)聽el-select選擇值的變化,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue實(shí)現(xiàn)登陸登出的實(shí)現(xiàn)示例

    vue實(shí)現(xiàn)登陸登出的實(shí)現(xiàn)示例

    本篇文章主要介紹了vue實(shí)現(xiàn)登陸登出的實(shí)現(xiàn)示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09

最新評論