Skip to content

Commit 8339f14

Browse files
committed
fix: ref line duplicate keys
1 parent 5adf53b commit 8339f14

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/components/viewport/ref-lines.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
22
<div class="guides" v-show="moving">
33
<!-- 横线 -->
4-
<div class="horiz" :key="val + i" v-for="(val, i) in horiz"
5-
:style="{top: val + 'px'}"
6-
v-show="attachHoriz(val)"></div>
4+
<div class="horiz" :key="val.id" v-for="val in horiz"
5+
:style="{top: val.val + 'px'}"
6+
v-show="attachHoriz(val.val)"></div>
77

88
<!-- 竖线 -->
9-
<div class="verti" :key="val + i" v-for="(val, i) in verti"
10-
:style="{left: val + 'px'}"
11-
v-show="attachVerti(val)"></div>
9+
<div class="verti" :key="val.id" v-for="val in verti"
10+
:style="{left: val.val + 'px'}"
11+
v-show="attachVerti(val.val)"></div>
1212
</div>
1313
</template>
1414

@@ -40,6 +40,7 @@ export default {
4040
if (item.hasGuide && item.belong !== 'page') return
4141
4242
guides.push({
43+
uuid: item.uuid,
4344
width: item.width,
4445
height: item.height,
4546
top: item.top,
@@ -66,10 +67,16 @@ export default {
6667
var bottom = top + val.height
6768
6869
if (cor.indexOf(top) < 0 && top !== 0) {
69-
cor.push(top)
70+
cor.push({
71+
id: `horiz-${val.uuid}-${top}`,
72+
val: top
73+
})
7074
}
7175
if (cor.indexOf(bottom) < 0) {
72-
cor.push(bottom)
76+
cor.push({
77+
id: `horiz-${val.uuid}-${bottom}`,
78+
val: bottom
79+
})
7380
}
7481
})
7582
@@ -85,10 +92,16 @@ export default {
8592
var right = left + val.width
8693
8794
if (cor.indexOf(left) < 0 && left !== 0) {
88-
cor.push(left)
95+
cor.push({
96+
id: `verti-${val.uuid}-${left}`,
97+
val: left
98+
})
8999
}
90100
if (cor.indexOf(right) < 0 && right < 750) {
91-
cor.push(right)
101+
cor.push({
102+
id: `verti-${val.uuid}-${right}`,
103+
val: right
104+
})
92105
}
93106
})
94107

0 commit comments

Comments
 (0)