mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
feat: 新增 @pureadmin/table 行、列拖拽示例
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import Sortable from "sortablejs";
|
||||
import { ref, onMounted } from "vue";
|
||||
import Sortable, { Swap } from "sortablejs";
|
||||
import draggable from "vuedraggable/src/vuedraggable";
|
||||
import { useAppStoreHook } from "@/store/modules/app";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
|
||||
defineOptions({
|
||||
name: "Draggable"
|
||||
});
|
||||
|
||||
const { setSortSwap } = useAppStoreHook();
|
||||
|
||||
const gridLists = ref<Array<Object>>([
|
||||
{ grid: "cn", num: 1 },
|
||||
{ grid: "cn", num: 2 },
|
||||
@@ -39,7 +42,8 @@ const change = (evt): void => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 使用原生sortable实现元素位置切换
|
||||
if (!useAppStoreHook().sortSwap) Sortable.mount(new Swap());
|
||||
setSortSwap(true);
|
||||
new Sortable(document.querySelector(".cut-container"), {
|
||||
swap: true,
|
||||
forceFallback: true,
|
||||
@@ -121,7 +125,7 @@ onMounted(() => {
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>拖拽实现元素位置切换</span>
|
||||
<span>拖拽实现元素位置交换</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 拖拽实现元素位置切换 -->
|
||||
|
||||
Reference in New Issue
Block a user