是这样的,我的Vue3DraggableResizable父级宽度高度尺寸会变化,Vue3DraggableResizable的parent属性设置为true,但是拖拽范围没有随父级宽度高度尺寸而变化,解决方式是给父级容器加key,强制刷新
javascript
<div ref="textDivContainer"
class="all-div-container"
:style="{'width':bottomCenterWidth + 'px','height':bottomCenterHeight + 'px'}"
:key="`container-${bottomCenterWidth}-${bottomCenterHeight}`"
>
<Vue3DraggableResizable
v-for="component in allComponents"
:key="component.id"
:initW="component.width"
:initH="component.height"
v-model:x="component.x"
v-model:y="component.y"
v-model:w="component.width"
v-model:h="component.height"
v-model:active="component.active"
:parent="true"
:draggable="!isComponentLocked(component.id)"
:resizable="!isComponentLocked(component.id)"
:handles="['tl','tm','tr','mr','br','bm','bl','ml']"
class="draggable-resizable-wrapper"
@resizing="(size) => handleComponentResizing(component.id, size)"
@dragging="(position) => handleComponentDragging(component.id, position)"
@activated="() => handleComponentActivated(component.id)"
@deactivated="() => handleComponentDeactivated(component.id)"
>
<component
:is="getComponent(component)"
v-if="getComponent(component)"
v-bind="getComponentProps(component)"
:ref="(el) => {
if (component.type === 'model3d' && el) {
threeDimModuleRefs.set(component.id, el)
} else if (component.type === 'model3d' && !el) {
threeDimModuleRefs.delete(component.id)
}
}"
@update="handleComponentTextUpdate(component.id, $event)"
/>
</Vue3DraggableResizable>
</div>