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
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,23 +15,25 @@ Note that this library is small enough (see [Sortable.vue](https://github.com/Ma
15
15
-`shopify/draggable` and [`vue-shopify-dragable`](https://github.com/zjffun/vue-shopify-draggable) seemed promising but they don't supported nested components
16
16
17
17
## Usage
18
+
18
19
You can see a demo with more complete code at [https://sortablejs-vue3.maxleiter.com](https://sortablejs-vue3.maxleiter.com).
19
20
20
21
1. Install the package:
21
22
22
-
```bash
23
-
yarn add sortablejs-vue3 sortablejs
24
-
```
23
+
```bash
24
+
yarn add sortablejs-vue3 sortablejs
25
+
```
25
26
26
-
or
27
+
or
27
28
28
-
```bash
29
-
npm install sortablejs-vue3 sortablejs
30
-
```
29
+
```bash
30
+
npm install sortablejs-vue3 sortablejs
31
+
```
31
32
32
33
2. Import the component in your `<script setup>` (or `<script>`):
34
+
33
35
```typescript
34
-
import { Sortable } from'sortablejs-vue3'
36
+
import { Sortable } from"sortablejs-vue3";
35
37
```
36
38
37
39
3. Use the component:
@@ -59,6 +61,7 @@ import { Sortable } from 'sortablejs-vue3'
59
61
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`
60
62
61
63
### Events
64
+
62
65
You can listen to Sortable events by adding the listeners to the `Sortable` component. For example:
63
66
64
67
```typescript
@@ -81,6 +84,7 @@ You can listen to Sortable events by adding the listeners to the `Sortable` comp
81
84
```
82
85
83
86
### Vuex
87
+
84
88
No changes are necessary to work with Vuex. Just pass `store.state.item` 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