File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
src/components/DiyEditor/components/mobile/MagicCube Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div
3
3
class =" relative"
4
- :style =" { height: `${rowCount * CUBE_SIZE}px`, width: `${4 * CUBE_SIZE}px` }"
4
+ :style =" {
5
+ height: `${rowCount * CUBE_SIZE}px`,
6
+ width: `${4 * CUBE_SIZE}px`,
7
+ padding: `${property.space}px`
8
+ }"
5
9
>
6
10
<div
7
11
v-for =" (item, index) in property.list"
8
12
:key =" index"
9
13
class =" absolute"
10
14
:style =" {
11
- width: `${item.width * CUBE_SIZE - property.space * 2}px`,
12
- height: `${item.height * CUBE_SIZE - property.space * 2}px`,
13
- margin: `${property.space}px`,
15
+ width: `${item.width * CUBE_SIZE - property.space}px`,
16
+ height: `${item.height * CUBE_SIZE - property.space}px`,
14
17
top: `${item.top * CUBE_SIZE}px`,
15
18
left: `${item.left * CUBE_SIZE}px`
16
19
}"
@@ -63,10 +66,10 @@ const rowCount = computed(() => {
63
66
let count = 0
64
67
if (props .property .list .length > 0 ) {
65
68
// 最大行号
66
- count = Math .max (... props .property .list .map ((item ) => item .bottom ))
69
+ count = Math .max (... props .property .list .map ((item ) => item .top + item . height ))
67
70
}
68
- // 行号从 0 开始,所以加 1
69
- return count + 1
71
+ // 保证至少有一行
72
+ return count == 0 ? 1 : count
70
73
})
71
74
</script >
72
75
You can’t perform that action at this time.
0 commit comments