vue-drag-drop is a lightweight Vue wrapper designed to simplify the often "wonky" native HTML Drag and Drop API. It aims to abstract away common pitfalls, such as the inability to access transferred data during `dragover` events, the need to manually serialize complex data types like objects and arrays, and the requirement for `event.preventDefault()` on drop zones. The current stable version is 1.1.4. While it does not specify a strict release cadence, updates have occurred since its major 1.0.0 release, which introduced significant changes. Key differentiators include its focus on simplicity and a minimal API, contrasting with more comprehensive drag-and-drop solutions that often include list reordering or extensive UI features. It is specifically built for Vue 2 applications and ships with TypeScript type definitions.
npm install vue-drag-dropVerified import paths — ran on the pinned version, not inferred.
This example demonstrates basic drag and drop functionality using `vue-drag-drop` components, showing how to transfer data and respond to `drop`, `dragenter`, and `dragleave` events, including visual feedback for the drop zone.
Always use the `transfer-data` prop on the `<Drag>` component to provide data, and access the transferred data through the event payload provided by `vue-drag-drop`'s custom events (e.g., `@drop`) on the `<Drop>` component, rather than attempting to read `event.dataTransfer` directly.
For Vue 3 projects, consider alternative drag-and-drop libraries or the native browser API. Do not attempt to use `vue-drag-drop` with Vue 3.
Evaluate your specific drag-and-drop needs. If you require advanced features like list reordering, virtualized lists with drag/drop, or complex UI interactions, explore libraries explicitly designed for those use cases instead of trying to extend `vue-drag-drop`.
Access the transferred data directly from the first argument of `vue-drag-drop`'s custom event handlers (e.g., `onDrop(data, event) { /* use data */ }`). The `transfer-data` prop is automatically made available here.Ensure you have either called `Vue.use(VueDragDrop)` globally or individually registered `Drag` and `Drop` components using `Vue.component('drag', Drag)` and `Vue.component('drop', Drop)` within your component's `components` option.Ensure that `vue.js` (or `vue.min.js`) is loaded *before* `vue-drag-drop.browser.js` in your HTML `<script>` tags, or if using a module bundler, ensure proper import order and configuration.