File tree Expand file tree Collapse file tree 3 files changed +64
-13
lines changed Expand file tree Collapse file tree 3 files changed +64
-13
lines changed Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html class ="no-js " lang ="">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < meta http-equiv ="x-ua-compatible " content ="ie=edge ">
6
+ < title > Basic example</ title >
7
+ < meta name ="description " content ="">
8
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
9
+
10
+ < link rel ="stylesheet " href ="css/main.css ">
11
+ </ head >
12
+ < body >
13
+
14
+ < div id ="main ">
15
+ < h1 > Vue Draggable</ h1 >
16
+
17
+ < div :class ="dragging? 'list-dragging' : 'drag' ">
18
+ < h2 > Draggable</ h2 >
19
+ < draggable :list ="list " @start ="dragging=true " @end ="dragging=false " :options ="{draggable:'.itemd'} ">
20
+ < div v-for ="element in list " class ="itemd " :key ="element.id "> {{element.name}}</ div >
21
+ < button slot ="footer " @click ="add "> Add People</ button >
22
+ </ draggable >
23
+ </ div >
24
+
25
+ < div class ="normal ">
26
+ < h2 > Normal v-for</ h2 >
27
+ < div >
28
+ < div v-for ="element in list "> {{element.name}}</ div >
29
+ </ div >
30
+ </ div >
31
+
32
+ < button @click ="replace "> Replace</ button >
33
+ < br >
34
+
35
+ < a href ="Two_Lists.html "> See 2 lists example</ a >
36
+ < a href ="Two_Lists_Clone.html "> See clone element example</ a >
37
+ < a href ="Two_Lists_Clone_If.html "> See clone v-if element example</ a >
38
+
39
+ </ div >
40
+
41
+ < script type ="text/javascript " src ="libs\vue\dist\vue.js "> </ script >
42
+ < script type ="text/javascript " src ="libs\Sortable\Sortable.js "> </ script >
43
+ < script type ="text/javascript " src ="src\vuedraggable.js "> </ script >
44
+ < script type ="text/javascript " src ="script\main.js "> </ script >
45
+ </ body >
46
+ </ html >
Original file line number Diff line number Diff line change
1
+ var id = 2 ;
2
+
1
3
var vm = new Vue ( {
2
4
el : "#main" ,
3
5
data : {
4
- list : [ { name : "John" } ,
5
- { name : "Joao" } ,
6
- { name : "Jean" } ] ,
6
+ list : [ { name : "John" , id : 0 } ,
7
+ { name : "Joao" , id : 1 } ,
8
+ { name : "Jean" , id : 2 } ] ,
7
9
dragging : false
8
10
} ,
9
11
methods :{
10
12
add : function ( ) {
11
- this . list . push ( { name :'Juan' } ) ;
13
+ this . list . push ( { name :'Juan ' + id , id : id ++ } ) ;
12
14
} ,
13
15
replace : function ( ) {
14
- this . list = [ { name :'Edgard' } ]
16
+ this . list = [ { name :'Edgard' , id : id ++ } ]
15
17
}
16
18
}
17
19
} ) ;
Original file line number Diff line number Diff line change 13
13
}
14
14
15
15
function insertNodeAt ( fatherNode , node , position ) {
16
- if ( position < fatherNode . children . length ) {
17
- fatherNode . insertBefore ( node , fatherNode . children [ position ] )
18
- } else {
19
- fatherNode . appendChild ( node )
20
- }
16
+ const refNode = ( position === 0 ) ? fatherNode . children [ 0 ] : fatherNode . children [ position - 1 ] . nextSibling
17
+ fatherNode . insertBefore ( node , refNode )
21
18
}
22
19
23
20
function computeVmIndex ( vnodes , element ) {
95
92
} ,
96
93
97
94
render ( h ) {
98
- if ( this . $slots . default && this . $slots . default . length === 1 ) {
99
- const child = this . $slots . default [ 0 ]
95
+ const slots = this . $slots . default
96
+ if ( slots && slots . length === 1 ) {
97
+ const child = slots [ 0 ]
100
98
if ( child . componentOptions && child . componentOptions . tag === "transition-group" ) {
101
99
this . transitionMode = true
102
100
}
103
101
}
104
- return h ( this . element , null , this . $slots . default ) ;
102
+ let children = [ ...slots ]
103
+ const { footer} = this . $slots
104
+ if ( footer ) {
105
+ children = [ ...slots , ...footer ]
106
+ }
107
+ return h ( this . element , null , children ) ;
105
108
} ,
106
109
107
110
mounted ( ) {
You can’t perform that action at this time.
0 commit comments