• 封装自定义表格组件


    技术栈: vue2.0 +js +webpack
    需求: 封装数据渲染的动态表格组件
    1.实现字典表的转译
    2.排序号的自动编译
    3.自定义字段
    4.操作栏的自定义

    封装组件代码:

    
    
    
    • 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
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140

    组件的使用:

    
    
    
    
    
    • 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

    数据:

    export const columns = [{
        prop: 'text',
        label: '名称',
      },
      {
        prop: 'current',
        label: '本期',
      },
      {
        prop: 'previous',
        label: '上月同期',
      },
      {
        prop: 'lastCurrent',
        label: '去年同期',
      },
      {
        prop: 'currentRatio',
        label: '环比(%)',
        html: (row) => {
          return row.currentRatio < 0 ? `${row.currentRatio}` : row.currentRatio;
        },
      }, {
        prop: 'lastCurrentRatio',
        label: '同比(%)',
        html: (row) => {
          return row.lastCurrentRatio < 0 ? `${row.lastCurrentRatio}` : row.lastCurrentRatio;
        },
      },
    ]
    
    
    export const tableData = [{
      text: 11,
      current: 11,
      previous: 'nini',
      lastCurrent: 22,
      currentRatio: 52525,
      lastCurrentRatio: -555
    }]
    
    • 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
  • 相关阅读:
    python库sqlalchemy使用教程
    SpringCloudAlibaba组件 — — OpenFeign的其他作用【超时时间、日志打印】
    L1-011 A-B分数 20
    Gitlab CI/CD介绍
    【JavaWeb的从0到1构建知识体系(三)】JDBC和Lombok的使用
    java调用科大讯飞离线语音合成SDK --内附完整项目
    SuperVariMag 超导磁体系统 — SVM 系列
    计算机专业的就业情况如何?
    2023八股每日一题(九月份)
    win10 火绒 每次打开word、excel都会提示,你要如何打开这个文件
  • 原文地址:https://blog.csdn.net/susanliy/article/details/132732262