1.安装插件
npm i vue-draggable-next
2.引入使用
<template>
<vue-draggable-next v-model="list" tag="div" handle=".warn-card" group="warngroup" ghost-class="ghost"
class="mb10 warn-card-box" animation="300">
<transition-group>
<div class="warn-card mb8" style="cursor: grab;" v-for="(item,index) in list" :key="index">
<div>{{ item }}</div>
</div>
</transition-group>
</vue-draggable-next>
</template>
<script setup>
import { VueDraggableNext } from 'vue-draggable-next'
import {ref} from "vue"
const list = ref(['洒了几滴','lksdf','哦靠平淡是福','点击分手快乐吧'])
</script>
3.效果
4.说明
在vue3中拖拽插件需要用vue-draggable-next,一般不能使用draggable,draggable会报错(会出现TypeError: Cannot read properties of undefined (reading header ))