vue使用vuedraggable实现列表拖动排序
程序员文章站
2022-03-07 18:28:13
文档地址安装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
上一篇: rem和em的区别
下一篇: 我学到的一些(DOM树操作)