I was trying to use vuedraggable into my Notebook application and i get this error when i add the draggable component. Here is the code and the error. I would appreciate the help.
Here is the error message i am getting.
Error: draggable element must have an item slot at computeNodes (webpack-internal:///./node_modules/vuedraggable/dist/vuedraggable.umd.js:4483:11) at computeComponentStructure (webpack-internal:///./node_modules/vuedraggable/dist/vuedraggable.umd.js:4525:15) at Proxy.render (webpack-internal:///./node_modules/vuedraggable/dist/vuedraggable.umd.js:4644:32) at renderComponentRoot (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:965:44) at componentEffect (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4382:53) at reactiveEffect (webpack-internal:///./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js:71:24) at effect (webpack-internal:///./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js:46:9) at setupRenderEffect (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4365:89) at mountComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4324:9) at processComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4284:17)
I am not using the vuedraggable component on my app.vue instead am passing it as a component from my todo.vue file.
Any help would be great. Thank you
Just surround your item in a <template #item>
tag, the error is saying to you that inside a draggeable
component must always be a slot called item
.
In Vue 3 you assign a template to a slot by using #{slotName}
Check this demo from the docs
example:
<draggable
:list="list"
:disabled="!enabled"
item-key="name"
class="list-group"
ghost-class="ghost"
:move="checkMove"
@start="dragging = true"
@end="dragging = false"
>
<template #item="{ element }">
<div class="list-group-item" :class="{ 'not-draggable': !enabled }">
{{ element.name }}
</div>
</template>
</draggable>