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

vue + element動(dòng)態(tài)多表頭與動(dòng)態(tài)插槽

 更新時(shí)間:2021年12月14日 09:40:35   作者:this_MyFunction  
這篇文章主要介紹了vue + element動(dòng)態(tài)多表頭與動(dòng)態(tài)插槽,下面文章圍繞vue + element動(dòng)態(tài)多表頭與動(dòng)態(tài)插槽的相關(guān)資料展開文章的內(nèi)容,具有一定的參考價(jià)值,需要的小伙伴可以參考一下,希望對(duì)大家有所幫助

一、需求

滿足用戶自行配置表格,減少對(duì)系統(tǒng)代碼維護(hù)量。

二、效果

表頭json:

說明:scope(字段名可另?。槭欠駥?duì)該列開啟插槽。有propChildren包含多級(jí)表頭。

   
tableHead: [{
    key: '1',
    label: '日期',
    prop: 'date',
    width: '100',
    headerAlign: 'center',
    align: 'center',
    scope: false,
    sortable: true
  },
  {
    key: '2',
    label: '姓名',
    prop: 'name',
    width: '100',
    headerAlign: 'center',
    align: 'center',
    scope: false,
    sortable: false
  },
  {
    key: '3',
    label: '分析情況',
    prop: 'analysis',
    width: '100',
    headerAlign: 'center',
    propChildren: [{
      key: '31',
      label: '同比',
      prop: 'TB',
      width: '100',
      headerAlign: 'center',
      align: 'center',
      scope: true,
      sortable: true
    },
    {
      key: '32',
      label: '環(huán)比',
      prop: 'HB',
      width: '100',
      headerAlign: 'center',
      align: 'center',
      scope: true,
      sortable: true
    },]
  },
  {
    key: '4',
    label: '金額',
    prop: 'price',
    width: '100',
    headerAlign: 'center',
    align: 'right',
    scope: false,
    sortable: true
  },
  {
    key: '5',
    label: '地址',
    prop: 'address',
    width: '',
    headerAlign: 'left',
    align: 'left',
    scope: false,
    sortable: false
  }
  ],

三、全部代碼

<template>
  <el-table
    :data="tableData"
    stripe
    resizable
    border
    height="300"
    style="width: 1000px"
  >
    <el-table-column
      type="index"
      :index="indexMethod"
      label="序號(hào)"
      align="center"
      width="60"
    >
    </el-table-column>
    <el-table-column
      v-for="(item, index) in tableHead"
      :key="index"
      :prop="item.prop"
      :label="item.label"
      :width="item.width"
      :align="item.align"
      :headerAlign="item.headerAlign"
      :sortable="item.sortable"
      show-overflow-tooltip
    >
      <el-table-column
        v-for="(item, index) in item.propChildren"
        :key="index"
        :prop="item.prop"
        :label="item.label"
        :width="item.width"
        :align="item.align"
        :headerAlign="item.headerAlign"
        :sortable="item.sortable"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <div v-if="item.scope === true">
            <div v-if="scope.row[item.prop] == ''">
              {{ scope.row[item.prop] }}
            </div>
            <div v-else-if="scope.row[item.prop] > '0'" style="color: green">
              {{ scope.row[item.prop] }}%<i class="el-icon-caret-top"></i>
            </div>
            <div v-else-if="scope.row[item.prop] < '0'" style="color: red">
              {{ scope.row[item.prop] }}%<i class="el-icon-caret-bottom"></i>
            </div>
          </div>
          <div v-else-if="scope.row[item.prop] < '0'" style="color: red">
            {{ scope.row[item.prop] }}
          </div>
          <div v-else>{{ scope.row[item.prop] }}</div>
        </template>
      </el-table-column>
      <template slot-scope="scope">
          <div v-if="item.scope === true">
            <div v-if="scope.row[item.prop] == ''">
              {{ scope.row[item.prop] }}
            </div>
            <div v-else-if="scope.row[item.prop] < '0'" style="color: red">
              {{ scope.row[item.prop] }}
            </div>
             <div v-else-if="scope.row[item.prop] > '0'">
              {{ scope.row[item.prop] }}
            </div>
          </div>
        <div v-else>{{ scope.row[item.prop] }}</div>
        </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data() {
    return {
      // 單表頭  是否對(duì)該列進(jìn)行數(shù)據(jù)比較,靠scope來判斷。
      tableHead: [{
        key: '1',
        label: '日期',
        prop: 'date',
        width: '100',
        headerAlign: 'center',
        align: 'center',
        scope: false,
        sortable: true
      },
      {
        key: '2',
        label: '姓名',
        prop: 'name',
        width: '100',
        headerAlign: 'center',
        align: 'center',
        scope: false,
        sortable: false
      },
      {
        key: '3',
        label: '分析情況',
        prop: 'analysis',
        width: '100',
        headerAlign: 'center',
        propChildren: [{
          key: '31',
          label: '同比',
          prop: 'TB',
          width: '100',
          headerAlign: 'center',
          align: 'center',
          scope: true,
          sortable: true
        },
        {
          key: '32',
          label: '環(huán)比',
          prop: 'HB',
          width: '100',
          headerAlign: 'center',
          align: 'center',
          scope: true,
          sortable: true
        },]
      },
      {
        key: '4',
        label: '金額',
        prop: 'price',
        width: '100',
        headerAlign: 'center',
        align: 'right',
        scope: false,
        sortable: true
      },
      {
        key: '5',
        label: '地址',
        prop: 'address',
        width: '',
        headerAlign: 'left',
        align: 'left',
        scope: false,
        sortable: false
      }
      ],

      // 數(shù)據(jù)
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        HB: '-1.1',
        TB: '2.5',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        HB: '-0.28',
        TB: '1.1',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        HB: '28',
        TB: '-0.11',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '張三',
        HB: '21',
        TB: '2.11',
        price: '-201.02',
        address: '上海市普陀區(qū)金沙江路 1516 弄'
      }, {
        date: '2016-05-11',
        name: '張三',
        HB: '0.28',
        TB: '-1.1',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路 1516 弄'
      }, {
        date: '2016-05-02',
        name: '王小虎',
        HB: '-0.18',
        TB: '-1.15',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路上海市普陀區(qū)金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        HB: '-1.01',
        TB: '1.1',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        HB: '-28',
        TB: '2.11',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '張三',
        HB: '',
        TB: '0.1',
        price: '-200.01',
        address: '上海市普陀區(qū)金沙江路 1516 弄'
      }, {
        date: '2016-05-11',
        name: '張三',
        HB: '18',
        TB: '-0.81',
        price: '2982.01',
        address: '上海市普陀區(qū)金沙江路 1516 弄'
      }],
    }
  },
  methods: {
    indexMethod(index) {
      return index + 1;
    }
  }
}
</script>

到此這篇關(guān)于vue + element動(dòng)態(tài)多表頭與動(dòng)態(tài)插槽的文章就介紹到這了,更多相關(guān)vue + element動(dòng)態(tài)多表頭與動(dòng)態(tài)插槽內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue?+?qiankun?項(xiàng)目搭建過程

    vue?+?qiankun?項(xiàng)目搭建過程

    這篇文章主要介紹了vue?+?qiankun?項(xiàng)目搭建,首先是通過cli3構(gòu)建vue2項(xiàng)目,通過qiankun改造主應(yīng)用,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-03
  • 解決vue-router 嵌套路由沒反應(yīng)的問題

    解決vue-router 嵌套路由沒反應(yīng)的問題

    這篇文章主要介紹了解決vue-router 嵌套路由沒反應(yīng)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • Vue中導(dǎo)入excel文件的兩種方式及使用步驟

    Vue中導(dǎo)入excel文件的兩種方式及使用步驟

    這篇文章主要介紹了Vue中導(dǎo)入excel文件的兩種方式,大概有兩種導(dǎo)入文件的方法:form表單和el-upload,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-12-12
  • vscode 開發(fā)Vue項(xiàng)目的方法步驟

    vscode 開發(fā)Vue項(xiàng)目的方法步驟

    這篇文章主要介紹了vscode 開發(fā)Vue項(xiàng)目的方法步驟,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-11-11
  • Vue.js自定義指令學(xué)習(xí)使用詳解

    Vue.js自定義指令學(xué)習(xí)使用詳解

    這篇文章主要為大家詳細(xì)介紹了Vue.js自定義指令的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-10-10
  • vue升級(jí)之路之vue-router的使用教程

    vue升級(jí)之路之vue-router的使用教程

    自動(dòng)安裝的vue-router,會(huì)在src 文件夾下有個(gè)一個(gè) router -> index.js 文件 在 index.js 中創(chuàng)建 routers 對(duì)象,引入所需的組件并配置路徑。這篇文章主要介紹了vue-router的使用,需要的朋友可以參考下
    2018-08-08
  • vue el-date-picker動(dòng)態(tài)限制時(shí)間范圍案例詳解

    vue el-date-picker動(dòng)態(tài)限制時(shí)間范圍案例詳解

    這篇文章主要介紹了vue el-date-picker動(dòng)態(tài)限制時(shí)間范圍案例詳解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-09-09
  • vue-resource請(qǐng)求實(shí)現(xiàn)http登錄攔截或者路由攔截的方法

    vue-resource請(qǐng)求實(shí)現(xiàn)http登錄攔截或者路由攔截的方法

    這篇文章主要介紹了vue-resource請(qǐng)求實(shí)現(xiàn)http登錄攔截或者路由攔截的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • vue實(shí)現(xiàn)路由懶加載及組件懶加載的方式

    vue實(shí)現(xiàn)路由懶加載及組件懶加載的方式

    懶加載簡(jiǎn)單來說就是延遲加載或按需加載,即在需要的時(shí)候的時(shí)候進(jìn)行加載。這篇文章主要介紹了vue路由懶加載及組件懶加載 ,需要的朋友可以參考下
    2019-06-06
  • axios攔截設(shè)置和錯(cuò)誤處理方法

    axios攔截設(shè)置和錯(cuò)誤處理方法

    下面小編就為大家分享一篇axios攔截設(shè)置和錯(cuò)誤處理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03

最新評(píng)論