Gathering detailed insights and metrics for vuedraggable-es-fix
Gathering detailed insights and metrics for vuedraggable-es-fix
Gathering detailed insights and metrics for vuedraggable-es-fix
Gathering detailed insights and metrics for vuedraggable-es-fix
Vue drag-and-drop component based on Sortable.js
npm install vuedraggable-es-fix
Typescript
Module System
Node Version
NPM Version
JavaScript (55.36%)
Vue (44.09%)
HTML (0.56%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
20,476 Stars
521 Commits
2,880 Forks
237 Watchers
28 Branches
32 Contributors
Updated on Jul 12, 2025
Latest Version
1.0.1
Package Id
vuedraggable-es-fix@1.0.1
Unpacked Size
51.98 kB
Size
12.89 kB
File Count
22
NPM Version
10.8.2
Node Version
20.18.0
Published on
Nov 18, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
28
1yarn add vuedraggable-es-fix // 改了个名字,esm模块,修复package.json的main指向 2 3npm i -S vuedraggable-es-fix
Vue ESM component (Vue.js 3.0) allowing drag-and-drop and synchronization with view model array.
For Vue 2 and Vue 1 version check: https://github.com/SortableJS/Vue.Draggable
Based on and offering all features of Sortable.js
https://sortablejs.github.io/vue.draggable.next/
tag
and componentData
propsFind this project useful? You can buy me a :coffee: or a :beer:
1 2<script src="//cdnjs.cloudflare.com/ajax/libs/vue/3.0.2/vue.min.js"></script> 3<!-- CDNJS :: Sortable (https://cdnjs.com/) --> 4<script src="//cdn.jsdelivr.net/npm/sortablejs@1.10.2/Sortable.min.js"></script> 5<!-- CDNJS :: Vue.Draggable (https://cdnjs.com/) --> 6<script src="//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/4.0.0/vuedraggable.umd.min.js"></script> 7
1<draggable 2 v-model="myArray" 3 group="people" 4 @start="drag=true" 5 @end="drag=false" 6 item-key="id"> 7 <template #item="{element}"> 8 <div>{{element.name}}</div> 9 </template> 10</draggable>
1 import draggable from 'vuedraggable' 2 ... 3 export default { 4 components: { 5 draggable, 6 }, 7 data() { 8 return { 9 drag: false, 10 } 11 }, 12 ...
The item
slot should be used to display items of the list. It receives the element value and the element index as slot-props.
transition-group
:1<draggable v-model="myArray" tag="transition-group" item-key="id"> 2 <template #item="{element}"> 3 <div> {{element.name}} </div> 4 </template> 5</draggable>
1<draggable v-model="myArray" item-key="id"> 2 <template #item="{element}"> 3 <div> {{element.name}} </div> 4 </template> 5 <template #footer> 6 <button @click="addPeople">Add</button> 7 </template> 8</draggable>
1<draggable v-model="myArray" item-key="id"> 2 <template #item="{element}"> 3 <div> {{element.name}} </div> 4 </template> 5 <template #header> 6 <button @click="addPeople">Add</button> 7 </template> 8</draggable>
1<draggable v-model='myList'>
1computed: { 2 myList: { 3 get() { 4 return this.$store.state.myList 5 }, 6 set(value) { 7 this.$store.commit('updateList', value) 8 } 9 } 10}
Breaking changes:
item
slot instead of default to display elementsitemKey
propsFrom:
1<!-- vue 2 version --> 2<draggable v-model="myArray"> 3 <div v-for="element in myArray" :key="element.id">{{element.name}}</div> 4</draggable>
To:
1<draggable v-model="myArray" item-key="id"> 2 <template #item="{element}"> 3 <div>{{element.name}}</div> 4 </template> 5</draggable>
Breaking changes:
3) When using transition, you should now use the tag
props and componentData
to create the transition
From
1<!-- vue 2 version --> 2<draggable v-model="myArray"> 3 <transition-group name="fade"> 4 <div v-for="element in myArray" :key="element.id"> 5 {{element.name}} 6 </div> 7 </transition-group> 8</draggable>
to
1<draggable v-model="myArray" tag="transition-group" :component-data="{name:'fade'}"> 2 <template #item="{element}"> 3 <div>{{element.name}}</div> 4 </template> 5</draggable>
Type: Array
Required: false
Default: null
Input array to draggable component. Typically same array as referenced by inner element v-for directive.
This is the preferred way to use Vue.draggable as it is compatible with Vuex.
It should not be used directly but only though the v-model
directive:
1<draggable v-model="myArray">
Type: Array
Required: false
Default: null
Alternative to the modelValue
prop, list is an array to be synchronized with drag-and-drop.
The main difference is that list
prop is updated by draggable component using splice method, whereas modelValue
is immutable.
Do not use in conjunction with modelValue prop.
Type: String
or Function
Required: true
The property to be used as the element key. Alternatively a function receiving an element of the list and returning its key.
Sortable options can be set directly as vue.draggable props since version 2.19.
This means that all sortable option are valid sortable props with the notable exception of all the method starting by "on" as draggable component expose the same API via events.
kebab-case property are supported: for example ghost-class
props will be converted to ghostClass
sortable option.
Example setting handle, sortable and a group option:
1<draggable 2 v-model="list" 3 handle=".handle" 4 :group="{ name: 'people', pull: 'clone', put: false }" 5 ghost-class="ghost" 6 :sort="false" 7 @change="log" 8 > 9 <!-- --> 10</draggable>
Type: String
Default: 'div'
HTML node type of the element that draggable component create as outer element for the included slot.
It is also possible to pass the name of vue component as element. In this case, draggable attribute will be passed to the create component.
See also componentData if you need to set props or event to the created component.
Type: Function
Required: false
Default: (original) => { return original;}
Function called on the source component to clone element when clone option is true. The unique argument is the viewModel element to be cloned and the returned value is its cloned version.
By default vue.draggable reuses the viewModel element, so you have to use this hook if you want to clone or deep clone it.
Type: Function
Required: false
Default: null
If not null this function will be called in a similar way as Sortable onMove callback. Returning false will cancel the drag operation.
1function onMoveCallback(evt, originalEvent){ 2 ... 3 // return false; — for cancel 4}
evt object has same property as Sortable onMove event, and 3 additional properties:
draggedContext
: context linked to dragged element
index
: dragged element indexelement
: dragged element underlying view model elementfutureIndex
: potential index of the dragged element if the drop operation is acceptedrelatedContext
: context linked to current drag operation
index
: target element indexelement
: target element view model elementlist
: target listcomponent
: target VueComponentHTML:
1<draggable :list="list" :move="checkMove">
javascript:
1checkMove: function(evt){ 2 return (evt.draggedContext.element.name!=='apple'); 3}
See complete example: Cancel.html, cancel.js
Type: Object
Required: false
Default: null
This props is used to pass additional information to child component declared by tag props.
Value: an object corresponding to the attributes, props and events we would pass to the component.
Example (using element UI library):
1<draggable tag="el-collapse" :list="list" :component-data="getComponentData()" item-key="name"> 2 <template #item="{element}"> 3 <el-collapse-item :title="element.title" :name="element.name"> 4 <div>{{element.description}}</div> 5 </el-collapse-item> 6 </template> 7</draggable>
1methods: { 2 handleChange() { 3 console.log('changed'); 4 }, 5 inputChanged(value) { 6 this.activeNames = value; 7 }, 8 getComponentData() { 9 return { 10 onChange: this.handleChange, 11 onInput: this.inputChanged, 12 wrap: true, 13 value: this.activeNames 14 }; 15 } 16 }
Support for Sortable events:
start
, add
, remove
, update
, end
, choose
, unchoose
, sort
, filter
, clone
Events are called whenever onStart, onAdd, onRemove, onUpdate, onEnd, onChoose, onUnchoose, onSort, onClone are fired by Sortable.js with the same argument.
See here for reference
Note that SortableJS OnMove callback is mapped with the move prop
HTML:
1<draggable :list="list" @end="onEnd">
change event
change
event is triggered when list prop is not null and the corresponding array is altered due to drag-and-drop operation.
This event is called with one argument containing one of the following properties:
added
: contains information of an element added to the array
newIndex
: the index of the added elementelement
: the added elementremoved
: contains information of an element removed from to the array
oldIndex
: the index of the element before removeelement
: the removed elementmoved
: contains information of an element moved within the array
newIndex
: the current index of the moved elementoldIndex
: the old index of the moved elementelement
: the moved elementThe item
slot is used to display one element of the list. Vue.draggable will iterate the list and call this slot for each element.
Slot props:
element
the element in the listindex
the element indexIt is the only required slot.
1<draggable v-model="myArray" item-key="id"> 2 <template #item="{element, index}"> 3 <div> {{index}} - {{element.name}} </div> 4 </template> 5</draggable>
Use the header
slot to add none-draggable element inside the vuedraggable component.
Ex:
1<draggable v-model="myArray" item-key="id"> 2 <template #item="{element}"> 3 <div> {{element.name}} </div> 4 </template> 5 <template #header> 6 <button @click="addPeople">Add</button> 7 </template> 8</draggable>
Use the footer
slot to add none-draggable element inside the vuedraggable component.
Ex:
1<draggable v-model="myArray" item-key="id"> 2 <template #item="{element}"> 3 <div> {{element.name}} </div> 4 </template> 5 <template #footer> 6 <button @click="addPeople">Add</button> 7 </template> 8</draggable>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/19 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
106 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More