1.安装并引入Sortable插件
2.直接获取需要拖动的dom节点
javascript"><template><div><ul id="list"><li v-for="item in list1" :key="item.id" :data-id="item.id" v-on:drag="saveDragItem">{{ item.name }}</li></ul></div>
</template>
<script lang="ts" setup>
import { ref, reactive, onMounted, nextTick } from 'vue'
import Sortable from "sortablejs";
const list1 = ref([{ id: 1, name: '项目1' },{ id: 2, name: '项目2' },{ id: 3, name: '项目3' }
])
onMounted(() => {new Sortable(document.getElementById('list'), {group: 'shared',animation: 150,});
})