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
| Component({
| /**
| * 外部样式类
| */
| externalClasses: ['header-row-class-name', 'row-class-name', 'cell-class-name'],
|
| /**
| * 组件样式隔离
| */
| options: {
| styleIsolation: "isolated",
| multipleSlots: true, // 支持多个slot
| },
|
| /**
| * 组件的属性列表
| */
| properties: {
| data: {
| type: Array,
| value: []
| },
| headers: {
| type: Array,
| value: []
| },
| // table的高度, 溢出可滚动
| height: {
| type: String,
| value: 'auto'
| },
| width: {
| type: Number || String,
| value: '100%'
| },
| // 单元格的宽度
| tdWidth: {
| type: Number,
| value: 35
| },
| // 固定表头 thead达到Header的位置时就应该被fixed了
| offsetTop: {
| type: Number,
| value: 150
| },
| // 是否带有纵向边框
| stripe: {
| type: Boolean,
| value: false
| },
| // 是否带有纵向边框
| border: {
| type: Boolean,
| value: false
| },
| msg: {
| type: String,
| value: '暂无数据~'
| }
| },
|
| /**
| * 组件的初始数据
| */
| data: {
| scrolWidth: '100%'
| },
|
| /**
| * 组件的监听属性
| */
| observers: {
| // 在 numberA 或者 numberB 被设置时,执行这个函数
| 'headers': function (headers) {
| const reducer = (accumulator, currentValue) => {
| return accumulator + Number(currentValue.width)
| };
| const scrolWidth = headers.reduce(reducer, 0)
|
| this.setData({
| scrolWidth: scrolWidth
| })
| }
| },
|
| /**
| * 组件的方法列表
| */
| methods: {
| onRowClick(e) {
| this.triggerEvent('rowClick', e, e.currentTarget.dataset.it)
| },
| }
| })
|
|