|
62 | 62 |
|
63 | 63 | ::: |
64 | 64 |
|
65 | | -### 斑马纹表格 |
| 65 | +### 表格样式 |
66 | 66 |
|
67 | | -:::demo 通过`d-table`组件上的`striped`属性,可设置带斑马纹的表格,更容易区分不同行的数据。 |
| 67 | +:::demo |
68 | 68 |
|
69 | 69 | ```vue |
70 | 70 | <template> |
71 | | - <d-table striped :data="stripedTableData"> |
| 71 | +<div class="table-btn-groups"> |
| 72 | + <div class="table-btn"> |
| 73 | + 自动表格布局: |
| 74 | + <d-switch v-model:checked="tableLayout" /> |
| 75 | + </div> |
| 76 | + <div class="table-btn"> |
| 77 | + 斑马纹: |
| 78 | + <d-switch v-model:checked="striped" /> |
| 79 | + </div> |
| 80 | + <div class="table-btn"> |
| 81 | + 表头背景色: |
| 82 | + <d-switch v-model:checked="headerBg" /> |
| 83 | + </div> |
| 84 | + </div> |
| 85 | + <d-table :table-layout="tableLayout?'auto':'fixed'" :striped="striped" :header-bg="headerBg" :data="stripedTableData"> |
72 | 86 | <d-column field="firstName" header="First Name"></d-column> |
73 | 87 | <d-column field="lastName" header="Last Name"></d-column> |
74 | 88 | <d-column field="gender" header="Gender"></d-column> |
|
82 | 96 |
|
83 | 97 | export default defineComponent({ |
84 | 98 | setup() { |
85 | | -
|
| 99 | + const tableLayout = ref(false) |
| 100 | + const striped = ref(false) |
| 101 | + const headerBg = ref(false) |
86 | 102 | const stripedTableData = ref([ |
87 | 103 | { |
88 | 104 | firstName: 'Mark', |
|
110 | 126 | } |
111 | 127 | ]) |
112 | 128 |
|
113 | | - return { stripedTableData } |
| 129 | + return { |
| 130 | + stripedTableData, |
| 131 | + striped, |
| 132 | + headerBg, |
| 133 | + tableLayout |
| 134 | + } |
114 | 135 | } |
115 | 136 | }) |
116 | 137 | </script> |
| 138 | +
|
| 139 | +<style lang="scss"> |
| 140 | +.table-btn-groups{ |
| 141 | + display: flex; |
| 142 | + margin-bottom: 1rem; |
| 143 | +} |
| 144 | +.table-btn{ |
| 145 | + display: flex; |
| 146 | + flex-direction: column; |
| 147 | + justify-content: space-between; |
| 148 | +} |
| 149 | +</style> |
117 | 150 | ``` |
118 | 151 |
|
119 | 152 | ::: |
|
182 | 215 |
|
183 | 216 | ### d-table Props |
184 | 217 |
|
185 | | -| 参数 | 类型 | 默认值 | 说明 | |
186 | | -| ------- | --------- | ------- | ------------------ | |
187 | | -| data | `Array` | `[]` | 显示的数据 | |
188 | | -| striped | `Boolean` | `false` | 是否显示斑马纹间隔 | |
| 218 | +| 参数 | 类型 | 默认值 | 说明 | |
| 219 | +| ------------ | ------------------- | --------- | ------------------------ | |
| 220 | +| data | `Array` | `[]` | 显示的数据 | |
| 221 | +| striped | `Boolean` | `false` | 是否显示斑马纹间隔 | |
| 222 | +| header-bg | `Boolean` | `false` | 可选,表头是否显示背景色 | |
| 223 | +| table-layout | `String` | `'fixed'` | 表格布局,可选值为`'auto'`| |
189 | 224 |
|
190 | 225 | ### d-column Props |
191 | 226 |
|
192 | | -| 参数 | 类型 | 默认值 | 说明 | |
193 | | -| ------ | ------------------ | ------ | ---------------------- | |
194 | | -| header | `String` | `-` | 对应列的标题 | |
195 | | -| field | `String` | `-` | 对应列内容的字段名 | |
196 | | -| width | `String \| Number` | `-` | 对应列的宽度,单位`px` | |
197 | | -| min-width | `String \| Number` | `-` | 对应列的最小宽度,单位`px` | |
| 227 | +| 参数 | 类型 | 默认值 | 说明 | |
| 228 | +| --------- | ------------------ | ------ | -------------------------- | |
| 229 | +| header | `String` | `-` | 对应列的标题 | |
| 230 | +| field | `String` | `-` | 对应列内容的字段名 | |
| 231 | +| width | `String \| Number` | `-` | 对应列的宽度,单位`px` | |
| 232 | +| min-width | `String \| Number` | `-` | 对应列的最小宽度,单位`px` | |
0 commit comments