当前位置:   article > 正文

elementui的el-table使用无限滚动加载_element table 动态无限滚动

element table 动态无限滚动

先下载 npm install --save el-table-infinite-scroll
会报错
在这里插入图片描述全局引入main.js

import elTableInfiniteScroll from 'el-table-infinite-scroll';
Vue.use(elTableInfiniteScroll);
  • 1
  • 2

局部引入

<script>
2 import elTableInfiniteScroll from 'el-table-infinite-scroll';
3 export default {
4   directives: {
5     'el-table-infinite-scroll': elTableInfiniteScroll
6   }
7 }
8 </script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

找到下载的js把对应报错注释掉
在这里插入图片描述

<el-table
    ref="singleTable"
    :data="tableData"
   v-el-table-infinite-scroll="load"
    @row-click="changeRow"
    :row-style="isRed"
    class="table">
    <el-table-column
      property="status"
      label="设备状态">
    </el-table-column>
    <el-table-column
      property="name"
      label="作业状态">
    </el-table-column>
    <el-table-column
      property="address"
      label="工单号">
    </el-table-column>
     <el-table-column
      property="date"
      label="产品">
    </el-table-column>
     <el-table-column
      property="date"
      label="产出单位">
    </el-table-column>
     <el-table-column
      property="date"
      label="工序">
    </el-table-column>


  </el-table>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
data() {
      return {
        checked:false,
        tableData: [{
          status:'生产中',
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄',
          index:0
        }, {
          status:'生产中',
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄',
          index:1
        }, {
          status:'生产中',
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄',
          index:2
        }, {
          status:'生产中',
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄',
          index:3
        },{
          status:'生产中',
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄',
          index:0
        }, {
          status:'生产中',
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄',
          index:1
        }, {
          status:'生产中',
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄',
          index:2
        }, {
          status:'生产中',
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄',
          index:3
        },{
          status:'生产中',
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄',
          index:0
        }, {
          status:'生产中',
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄',
          index:1
        }, {
          status:'生产中',
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄',
          index:2
        }, {
          status:'生产中',
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄',
          index:3
        },],
        currentRow: null,
        changeList:[],
        count:1
      }
    },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
methods: {
      load () {
        this.count += 1
        console.log(this.count)
       this.aa()
        // console.log(this.tableData)
      },
      aa(){
         var arr=[{
          status:'生产中',
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄',
          index:4
        }]
        arr.forEach(item=>{
          item.status = '生产中'+this.count
        })
        console.log('111')
        this.tableData=this.tableData.concat(this.tableData)
      },
   }
   //有志同道合的朋友可以一起加群讨论: 330586621
//想要进微信群,qq里面加我联系
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/193911?site
推荐阅读
相关标签
  

闽ICP备14008679号