vue使用vuedraggable实现列表拖动排序
程序员文章站
2022-06-19 13:09:38
文档地址安装npm i -S vuedraggable引入import draggable from "vuedraggable";
文档地址
安装
npm i -S vuedraggable
引入
import draggable from "vuedraggable";
<template>
<div class="box">
<draggable v-model="list" chosenClass="active" animation="500" @end="dragEnd">
<div class="row" v-for="(item,index) in list" :key="index">{{item}}</div>
</draggable>
</div>
</template>
<script>
import draggable from "vuedraggable";
export default {
components: {
draggable
},
data() {
return {
list: [1, 2, 3, 4, 5, 6, 7]
};
},
methods: {
dragEnd() {
console.log(this.list);
}
}
};
</script>
<style scoped>
.row {
background: cadetblue;
width: 100%;
height: 150px;
line-height: 150px;
text-align: center;
margin: 15px 0;
}
.active {
background: chocolate !important;
}
</style>
本文地址:https://blog.csdn.net/hql1024/article/details/110222919
上一篇: Javascript继承3:将优点为我所有----组合式继承
下一篇: Vue过滤器及小demo