mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
parent
4ffb2d164c
commit
a0e5776ea3
@ -134,10 +134,12 @@ describe('Descriptions.vue', () => {
|
||||
<el-descriptions-item label="1">1</el-descriptions-item>
|
||||
<el-descriptions-item label="2" :span="2">2</el-descriptions-item>
|
||||
<el-descriptions-item label="3">3</el-descriptions-item>
|
||||
<el-descriptions-item label="4">4</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`)
|
||||
|
||||
expect(wrapper.findAll('td')[1].element.getAttribute('colSpan')).toEqual('2')
|
||||
expect(wrapper.findAll('td')[3].element.getAttribute('colSpan')).toEqual('2')
|
||||
})
|
||||
|
||||
test('re-rendered when slots is updated', async () => {
|
||||
|
@ -90,8 +90,8 @@ export default defineComponent({
|
||||
node.props.span = count
|
||||
}
|
||||
if (isLast) {
|
||||
// set the max span, cause of the last td
|
||||
node.props.span = props.column
|
||||
// set the last span
|
||||
node.props.span = span
|
||||
}
|
||||
return node
|
||||
}
|
||||
@ -101,12 +101,19 @@ export default defineComponent({
|
||||
const rows = []
|
||||
let temp = []
|
||||
let count = props.column
|
||||
let totalSpan = 0 // all spans number of item
|
||||
|
||||
children.forEach((node, index) => {
|
||||
const span = node.props?.span || 1
|
||||
let span = node.props?.span || 1
|
||||
|
||||
if (index < children.length - 1) {
|
||||
totalSpan += span > count ? count : span
|
||||
}
|
||||
|
||||
if (index === children.length - 1) {
|
||||
temp.push(filledNode(node, span, count, true))
|
||||
// calculate the last item span
|
||||
const lastSpan = props.column - totalSpan % props.column
|
||||
temp.push(filledNode(node, lastSpan, count, true))
|
||||
rows.push(temp)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user