You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ import { Sortable } from "sortablejs-vue3";
36
36
37
37
3. Use the component:
38
38
39
-
```typescript
39
+
```vue
40
40
<template>
41
41
<main>
42
42
<Sortable
@@ -45,18 +45,24 @@ import { Sortable } from "sortablejs-vue3";
45
45
tag="div"
46
46
:options="options"
47
47
>
48
+
<-- The Header and Footer templates below are optional -->
49
+
<template #header>
50
+
<h1>SortableJS Vue3 Demo</h1>
51
+
</template>
48
52
<template #item="{element, index}">
49
53
<div class="draggable" :key="element.id">
50
54
{{ element.name }}
51
55
</div>
52
56
</template>
57
+
<template #footer>
58
+
<div class="draggable">A footer</div>
59
+
</template>
53
60
</Sortable>
54
61
</template>
55
62
```
56
63
57
64
4. The `list` and `item-key` props are necessary. The `options` prop is an object that can contain any SortableJS option. You can find a full list of them here: https://github.com/SortableJS/Sortable#options
58
-
59
-
5. The `tag` prop is an optional prop, it's the HTML node type of the element that creates an outer element for the included slot. the default value is `div`
65
+
- The `tag` prop is optional and defaults to `div`. It's the HTML node type for the outer element of the included template/slot.
60
66
61
67
### Props
62
68
@@ -88,9 +94,9 @@ You can listen to Sortable events by adding the listeners to the `Sortable` comp
88
94
>
89
95
```
90
96
91
-
### Vuex
97
+
### Use with a Store
92
98
93
-
No changes are necessary to work with Vuex. Just pass `store.state.items` as your list. To modify your data you need to manually listen to the events and calculate the new position with `event.oldIndex` and `event.newIndex` with something like the following:
99
+
No changes are necessary to work with Vuex or another store. Just pass `store.state.items` as your list. To modify your data you need to manually listen to the events and calculate the new position with `event.oldIndex` and `event.newIndex` with something like the following:
0 commit comments