|
|
楼主 |
发表于 2024-6-3 10:56:34
|
显示全部楼层
函数使用
- <template>
- <div class="flex gap-2 p-4 w-300px h-300px m-auto bg-gray-500/5 rounded">
- <section ref="el1" class="w-[50%]">
- <div
- v-for="item in list1"
- :key="item.id"
- class="flex justify-between h-30 bg-gray-500/5 rounded p-3 cursor-move"
- >
- <span>{{ item.name }}</span>
- </div>
- </section>
- <section ref="el2" class="w-[50%]">
- <div
- v-for="item in list2"
- :key="item.id"
- class="flex justify-between h-30 bg-gray-500/5 rounded p-3 cursor-move"
- >
- <span>{{ item.name }}</span>
- </div>
- </section>
- </div>
- </template>
-
- <script setup lang="ts">
- import { ref } from "vue";
- import { type UseDraggableReturn, VueDraggable } from "vue-draggable-plus";
- import { useDraggable } from "vue-draggable-plus";
- const list1 = ref([
- {
- name: "风险编号",
- id: "riskNumber",
- },
- {
- name: "风险点等级",
- id: "rishLevel",
- },
- {
- name: "控制目标",
- id: "control target",
- },
- {
- name: "影响程度",
- id: "degree of influnce",
- },
- ]);
- const list2 = ref([
- {
- name: "曝光量",
- id: "open",
- },
- {
- name: "展示数",
- id: "show",
- },
- {
- name: "点击数",
- id: "click",
- },
- {
- name: "转化数",
- id: "buy",
- },
- ]);
- const el1 = ref();
- const el2 = ref();
- useDraggable(el1, list1, {
- animation: 150,
- ghostClass: "ghost",
- group: "number",
- });
- useDraggable(el2, list2, {
- animation: 150,
- ghostClass: "ghost",
- group: "number",
- });
- </script>
-
- <style scoped>
- .ghost {
- opacity: 0.5;
- background: #c8ebfb;
- }
- </style>
复制代码 |
|