parent
a6cd97ca9a
commit
f2d9e3105d
3 changed files with 23 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
|||
<template #item="{element}">
|
||||
<div :class="$style.item">
|
||||
<!-- divが無いとエラーになる https://github.com/SortableJS/vue.draggable.next/issues/189 -->
|
||||
<component :is="'x-' + element.type" :modelValue="element" @update:modelValue="updateItem" @remove="() => removeItem(element)"/>
|
||||
<component :is="getComponent(element.type)" :modelValue="element" @update:modelValue="updateItem" @remove="() => removeItem(element)"/>
|
||||
</div>
|
||||
</template>
|
||||
</Sortable>
|
||||
|
@ -16,6 +16,16 @@ import XText from './els/page-editor.el.text.vue';
|
|||
import XImage from './els/page-editor.el.image.vue';
|
||||
import XNote from './els/page-editor.el.note.vue';
|
||||
|
||||
function getComponent(type: string) {
|
||||
switch (type) {
|
||||
case 'section': return XSection;
|
||||
case 'text': return XText;
|
||||
case 'image': return XImage;
|
||||
case 'note': return XNote;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
|
||||
|
||||
const props = defineProps<{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue