Vue Dragula is a Vue.js wrapper for the popular Dragula library, providing simple drag-and-drop functionality primarily within Vue 2 applications. Its design allows for declarative drag-and-drop container setup using a custom `v-dragula` directive, integrating directly with Vue's data binding. The library exposes a global `Vue.vueDragula` API for setting bag-specific options, finding `drake` instances, and accessing an event bus for granular control over drag-and-drop events. This includes custom `dropModel` and `removeModel` events that expose `dropIndex` and `removeIndex` for easier model manipulation. The last stable release, 1.3.1, was in 2016 and primarily supports Vue 2.x. While a 2.0.0-alpha.1 version was released, it introduced significant breaking changes, indicated an unstable API, and the project appears to be no longer actively maintained, with no further stable releases or recent development activity.
npm install vue-dragulaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `vue-dragula` in a Vue 2 application, set up two drag-and-drop containers with a shared bag, configure bag-specific options, and listen for the `dropModel` event to react to model changes and log them to the console.
For Vue 3, consider alternative libraries like VueDraggable (based on Sortable.js) or implement drag-and-drop directly with native browser APIs or other Vue 3 compatible solutions.
Consider migrating to a actively maintained drag-and-drop library for Vue to ensure ongoing compatibility, bug fixes, and security updates.
Ensure all `v-for` iterations within `v-dragula` containers have a unique `:key` binding, e.g., `:key="item.id"` for objects or `:key="item"` for plain strings/numbers.
If encountering `2.0.0-alpha.1` specific issues, revert to `1.x.x` for stability, or update code to reflect the new plugin name (`Vue.dragula` or `this.$dragula`) and handle model updates manually based on `eventBus` events.
Add a unique `:key` attribute to each element inside the `v-for` loop within a `v-dragula` container. For example, `<div v-for="item in list" :key="item.id">` or `<div v-for="text in list" :key="text">`.
Ensure `Vue.use(VueDragula)` is called after `vue` and `vue-dragula` are loaded, typically at the application's entry point, before any Vue instances are created.
If using CommonJS, ensure `var VueDragula = require('vue-dragula');` is present. If using a direct script include, ensure the script tag for `vue-dragula` is after `vue` and `dragula` in your HTML.