当前位置:   article > 正文

Vue中的vxe-table教程23-高级表格-表尾数据、导出、全屏、隐藏列_vxe-table全屏

vxe-table全屏

效果图:

1. index.html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  7. <script src="https://cdn.jsdelivr.net/npm/xe-utils"></script>
  8. <script src="https://cdn.jsdelivr.net/npm/vxe-table"></script>
  9. <!-- 使用图标需引入图标对应的css文件即可使用-->
  10. <!-- 下载地址:http://www.fontawesome.com.cn/-->
  11. <link rel="stylesheet" href="./css/font-awesome.css">
  12. <!-- 使用 cdn 引用方式需要注意是否锁定版本,默认指向最新版本 -->
  13. </head>
  14. <body>
  15. <div id="app">
  16. <template>
  17. <div style="padding: 0 50px 0 50px">
  18. <vxe-grid
  19. border
  20. stripe
  21. resizable
  22. show-overflow
  23. show-footer
  24. height="500"
  25. :export-config="{}"
  26. :toolbar-config="tableToolbar"
  27. :footer-method="footerMethod"
  28. :columns="tableColumn"
  29. :data="tableData">
  30. </vxe-grid>
  31. </div>
  32. </template>
  33. </div>
  34. </body>
  35. <script src="./js/main.js"></script>
  36. <link rel="stylesheet" href="./css/main.css">
  37. </html>

2. main.css代码

@import url("https://cdn.jsdelivr.net/npm/vxe-table/lib/style.css");

3. main.js代码

  1. window.MOCK_DATA_LIST = [
  2. {"name": "mayanan", "sex": "男", "age": 29, "rate": 388},
  3. {"name": "mayanan", "sex": "男", "age": 29, "rate": 388},
  4. {"name": "mayanan", "sex": "男", "age": 27, "rate": 388},
  5. {"name": "mayanan", "sex": "男", "age": 27, "rate": 388},
  6. {"name": "mayanan", "sex": "男", "age": 25, "rate": 388},
  7. {"name": "mayanan", "sex": "男", "age": 25, "rate": 388},
  8. ];
  9. var Main = {
  10. data() {
  11. return {
  12. tableColumn: [
  13. {type: 'seq', width: 60},
  14. {field: 'name', title: "姓名"},
  15. {field: 'sex', title: "性别"},
  16. {field: 'age', title: '年龄', sortable: true},
  17. {field: 'rate', title: '速度'}
  18. ],
  19. tableToolbar: {
  20. export: true,
  21. zoom: true,
  22. custom: true
  23. },
  24. tableData: []
  25. }
  26. },
  27. created() {
  28. this.tableData = window.MOCK_DATA_LIST.slice(0, 15)
  29. },
  30. methods: {
  31. footerMethod({columns, data}) {
  32. return [
  33. columns.map((column, columnIndex) => {
  34. if (columnIndex === 0) {
  35. return '和值'
  36. }
  37. if (['age', 'rate'].includes(column.property)) {
  38. return XEUtils.sum(data, column.property)
  39. }
  40. return null
  41. }),
  42. columns.map((column, columnIndex) => {
  43. if (columnIndex === 0) {
  44. return '平均'
  45. }
  46. if (['age', 'rate'].includes(column.property)) {
  47. return XEUtils.mean(data, column.property)
  48. }
  49. return null
  50. })
  51. ]
  52. }
  53. }
  54. };
  55. var app = new Vue(Main).$mount('#app');
  56. // 给 vue 实例挂载内部对象,例如
  57. Vue.prototype.$XModal = VXETable.modal;
  58. Vue.prototype.$XPrint = VXETable.print;
  59. Vue.prototype.$XSaveFile = VXETable.saveFile;
  60. Vue.prototype.$XReadFile = VXETable.readFile;

 

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

闽ICP备14008679号