当前位置:   article > 正文

el-table的无限滚动(效果比虚拟滚动更优)_el-table-infinite-scroll

el-table-infinite-scroll

步骤

1. 前端安装“save el-table-infinite-scrol”

npm install --save el-table-infinite-scroll

2. 全局引用,在main.js中引用

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

3. 局部引用

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

4. 使用 

  1. <el-table
  2. class="elTable"
  3. border
  4. height="100%"
  5. :data="tableData"
  6. :span-method="spanMethod"
  7. :cell-class-name="cellClassName"
  8. :cell-style="{ borderColor: '#DBDBDB' }"
  9. :header-cell-style="{ borderColor: '#DBDBDB' }"
  10. v-loading="loading"
  11. v-el-table-infinite-scroll="loadTable"
  12. >
  13. </el-table>
  14. import elTableInfiniteScroll from "el-table-infinite-scroll";
  15. export default {
  16. name: "PlatForm",
  17. directives: {
  18. "el-table-infinite-scroll": elTableInfiniteScroll
  19. },
  20. data() {
  21. return {
  22. test:"test"
  23. };
  24. },
  25. methods: {
  26. // 加载table
  27. loadTable() {
  28. if (this.tableData.length < this.allData.length) {
  29. const data = this.tableData.concat(
  30. this.allData.slice(this.tableData.length, this.tableData.length + this.count)
  31. );
  32. this.$set(this, "tableData", data);
  33. }
  34. },
  35. }
  36. };

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/193953
推荐阅读