在vue项目中使用vuedraggable,进行的拖拽
1 npm install vuedraggable
2.import draggable from “vuedraggable”;
3.代码示例如下
<template>
<div class="fluid container">
<draggable
class="list-group"
tag="ul"
v-model="list"
v-bind="dragOptions"
@start="start()"
@end="end()"
>
<li class="list-group-item" v-for="item in list" :key="item.name">
<span>{{item}}</span>
</li>
</draggable>
</div>
</template>
<script>
import draggable from "vuedraggable";
export default {
name: "",
components: {
draggable
},
data() {
return {
list: [
//list的顺序为拖拽后的顺序
{ name: "123" },
{ name: "456" },
{ name: "789" },
{ name: "111" },
{ name: "222" },
{ name: "333" }
],
isDragging: {
animation: 300, //拖拽动画
disabled: false //是否禁用拖拽
}
};
},
created() {},
methods: {
start() {
//拖拽开始
},
end() {
//脱宅结束
}
},
computed: {}
};
</script>
<style>
</style>