Commit 0dc2f1496b00b941375772345efb262dea74364c
Committed by
GitHub
1 parent
dab977ff
fix: 合并单元格页面 由于 ant-design-vue 升级 v3 版本,页面报 Warning: columns.customRender 即将废弃,c…
…olumns.customRender 用 columns. customCell 替换 (#2520) * fix(MergeHeader): 组件/Table/合并单元格页面 修改 Tabel.title 值为 合并单元格、修改 Table.bordered 值为 true 更好显示合并单元格效果 * fix(tableData): 由于 ant-design-vue 升级 v3 版本,页面报 Warning: columns.customRender 即将废弃
Showing
2 changed files
with
18 additions
and
29 deletions
src/views/demo/table/MergeHeader.vue
src/views/demo/table/tableData.tsx
... | ... | @@ -157,29 +157,26 @@ export function getCustomHeaderColumns(): BasicColumn[] { |
157 | 157 | }, |
158 | 158 | ]; |
159 | 159 | } |
160 | -const renderContent = ({ text, index }: { text: any; index: number }) => { | |
161 | - const obj: any = { | |
162 | - children: text, | |
163 | - attrs: {}, | |
164 | - }; | |
165 | - if (index === 9) { | |
166 | - obj.attrs.colSpan = 0; | |
167 | - } | |
168 | - return obj; | |
169 | -}; | |
160 | + | |
161 | +const cellContent = (_, index) => ({ | |
162 | + colSpan: index === 9 ? 0 : 1, | |
163 | +}); | |
164 | + | |
170 | 165 | export function getMergeHeaderColumns(): BasicColumn[] { |
171 | 166 | return [ |
172 | 167 | { |
173 | 168 | title: 'ID', |
174 | 169 | dataIndex: 'id', |
175 | 170 | width: 300, |
176 | - customRender: renderContent, | |
171 | + customCell: (_, index) => ({ | |
172 | + colSpan: index === 9 ? 6 : 1, | |
173 | + }), | |
177 | 174 | }, |
178 | 175 | { |
179 | 176 | title: '姓名', |
180 | 177 | dataIndex: 'name', |
181 | 178 | width: 300, |
182 | - customRender: renderContent, | |
179 | + customCell: cellContent, | |
183 | 180 | }, |
184 | 181 | { |
185 | 182 | title: '地址', |
... | ... | @@ -187,19 +184,10 @@ export function getMergeHeaderColumns(): BasicColumn[] { |
187 | 184 | colSpan: 2, |
188 | 185 | width: 120, |
189 | 186 | sorter: true, |
190 | - customRender: ({ text, index }: { text: any; index: number }) => { | |
191 | - const obj: any = { | |
192 | - children: text, | |
193 | - attrs: {}, | |
194 | - }; | |
195 | - if (index === 2) { | |
196 | - obj.attrs.rowSpan = 2; | |
197 | - } | |
198 | - if (index === 3) { | |
199 | - obj.attrs.colSpan = 0; | |
200 | - } | |
201 | - return obj; | |
202 | - }, | |
187 | + customCell: (_, index) => ({ | |
188 | + rowSpan: index === 2 ? 2 : 1, | |
189 | + colSpan: index === 3 || index === 9 ? 0 : 1, | |
190 | + }), | |
203 | 191 | }, |
204 | 192 | { |
205 | 193 | title: '编号', |
... | ... | @@ -209,19 +197,19 @@ export function getMergeHeaderColumns(): BasicColumn[] { |
209 | 197 | { text: 'Male', value: 'male', children: [] }, |
210 | 198 | { text: 'Female', value: 'female', children: [] }, |
211 | 199 | ], |
212 | - customRender: renderContent, | |
200 | + customCell: cellContent, | |
213 | 201 | }, |
214 | 202 | { |
215 | 203 | title: '开始时间', |
216 | 204 | dataIndex: 'beginTime', |
217 | 205 | width: 200, |
218 | - customRender: renderContent, | |
206 | + customCell: cellContent, | |
219 | 207 | }, |
220 | 208 | { |
221 | 209 | title: '结束时间', |
222 | 210 | dataIndex: 'endTime', |
223 | 211 | width: 200, |
224 | - customRender: renderContent, | |
212 | + customCell: cellContent, | |
225 | 213 | }, |
226 | 214 | ]; |
227 | 215 | } | ... | ... |