From b75dd0b342712116e7defc37cff720706e8ed524 Mon Sep 17 00:00:00 2001 From: desmaisons_david Date: Sun, 5 Mar 2017 00:30:26 -0300 Subject: [PATCH] Update readme with v-for example --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 26886c48..fda00c33 100644 --- a/README.md +++ b/README.md @@ -36,21 +36,10 @@ Based on and offering all features of [Sortable.js](https://github.com/RubaXa/So Use draggable component: -Typical use: +### Typical use: ``` html - -
{{element.name}}
-
-``` - -With `transition-group`: -``` html - - -
- {{element.name}} -
-
+ +
{{element.name}}
``` .vue file: @@ -64,16 +53,61 @@ With `transition-group`: ... ``` +### With `transition-group`: +``` html + + +
+ {{element.name}} +
+
+
+``` + + Draggable component should directly wrap the draggable elements, or a `transition-component` containing the draggable elements. + +### With Vuex: + +```html + +``` + +```javascript +computed: { + myList: { + get() { + return this.$store.state.myList + }, + set(value) { + this.$store.commit('updateList', value) + } + } +} +``` + + ### Props +#### value +Type: `Array`
+Required: `false`
+Default: `null` + +Input array to draggable component. Typically same array as referenced by inner element v-for directive.
+Should not used directly but used only though the `v-model` directive: +```html + +``` + #### list Type: `Array`
Required: `false`
Default: `null` -Array to be synchronized with drag-and-drop. Typically same array as referenced by inner element v-for directive.
-When using children elements not linked to a "v-for" directive, use null. +Altenative to the `value` prop, list is an array to be synchronized with drag-and-drop.
+The main diference is that `list` prop is updated by draggable component using splice method, whereas `value` is immutable.
+Using `v-model` and `value` is the compatible with Vuex and thus is the preferred way of using draggable. #### options Type: `Object`