1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
| <template>
| <el-main>
| <el-alert title="感谢Vue3.0版本的vue.draggable.next拖拽组件 https://github.com/SortableJS/vue.draggable.next" type="success" style="margin-bottom:20px;"></el-alert>
| <div class="dragList">
| <draggable v-model="listA" animation="200" item-key="id" group="people">
| <template #item="{ element }">
| <div class="item">{{element.text}}</div>
| </template>
| </draggable>
| </div>
| <div class="dragList">
| <draggable v-model="listB" animation="200" item-key="id" group="people">
| <template #item="{ element }">
| <div class="item">{{element.text}}</div>
| </template>
| </draggable>
| </div>
| </el-main>
| </template>
|
| <script>
| import draggable from 'vuedraggable'
| export default {
| name: 'drag',
| components: {
| draggable
| },
| data() {
| return {
| listA: [
| {
| id: 1,
| text: 'A1'
| },
| {
| id: 2,
| text: 'A2'
| },
| {
| id: 3,
| text: 'A3'
| },
| {
| id: 4,
| text: 'A4'
| },
| {
| id: 5,
| text: 'A5'
| },
| {
| id: 6,
| text: 'A6'
| },
| {
| id: 7,
| text: 'A7'
| },
| {
| id: 8,
| text: 'A8'
| },
| {
| id: 9,
| text: 'A9'
| }
| ],
| listB: [
| {
| id: 1,
| text: 'B1'
| },
| {
| id: 2,
| text: 'B2'
| },
| {
| id: 3,
| text: 'B3'
| },
| {
| id: 4,
| text: 'B4'
| },
| {
| id: 5,
| text: 'B5'
| },
| {
| id: 6,
| text: 'B6'
| },
| {
| id: 7,
| text: 'B7'
| },
| {
| id: 8,
| text: 'B8'
| },
| {
| id: 9,
| text: 'B9'
| }
| ]
| }
| }
| }
| </script>
|
| <style scoped>
| .dragList {overflow: auto;}
| .item {cursor: move;float: left;background: #fff;width:100px;height: 100px;line-height: 100px;text-align: center;margin:0 15px 15px 0;border: 1px solid #e6e6e6;}
| .dragList .sortable-ghost {
| opacity: 0.5;
| }
| </style>
|
|