我在我的Vuejs/Nuxt应用程序中使用了Konvajs/Vue-Konva。我使用Konva在运行时动态创建Rect形状。我想知道是否有一种方法可以在每个形状中添加Text/Label。我想为每个Shape添加一个名称,以便分别标识每个Shape。
我已经在CodeSandBox中添加了我的代码示例。
有人可以告诉我如何将Text/Label添加到使用Vue-Konva创建的每个Rect/Shape中吗
发布于 2021-11-08 17:05:25
可以使用Konva.Group将多个形状组织到结构中。
<v-group
v-for="rec in nodeArray"
:key="'node' + rec.id"
:config="{
x: Math.min(rec.startPointX, rec.startPointX + rec.width),
y: Math.min(rec.startPointY, rec.startPointY + rec.height),
}"
@click="showEventInfoModal(rec.name)"
>
<v-rect
:key="'node' + rec.id"
:config="{
width: Math.abs(rec.width),
height: Math.abs(rec.height),
fill: 'rgb(0,0,0,0)',
stroke: 'black',
strokeWidth: 3,
draggable: true,
}"
/>
<v-text
:config="{
text: rec.name,
}"
/>
</v-group>https://stackoverflow.com/questions/69855544
复制相似问题