处理开始拖拽时的数据

This commit is contained in:
MTrun 2022-01-19 09:19:17 +08:00
parent 7262c4af22
commit ec5fccb945

View File

@ -1,6 +1,13 @@
<template> <template>
<div class="go-content-charts-item-box">
<!-- 每一项组件的渲染 --> <!-- 每一项组件的渲染 -->
<div class="item-box" v-for="(item, index) in menuOptions" :key="index"> <div
class="item-box"
v-for="(item, index) in menuOptions"
:key="index"
draggable
@dragstart="handleDragStart($event, item)"
>
<div class="list-header"> <div class="list-header">
<AppleControlBtn :mini="true" :disabled="true"></AppleControlBtn> <AppleControlBtn :mini="true" :disabled="true"></AppleControlBtn>
<n-text class="list-header-text" depth="3">{{ item.title }}</n-text> <n-text class="list-header-text" depth="3">{{ item.title }}</n-text>
@ -15,6 +22,7 @@
/> />
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -26,6 +34,14 @@ defineProps({
default: () => [] default: () => []
} }
}) })
//
const handleDragStart = (e: DragEvent, item: any) => {
if (e.dataTransfer instanceof Object && e.target instanceof Object) {
e.dataTransfer.setData('chartName', item.key)
e.dataTransfer.setData('chartNode', item.node)
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -33,7 +49,8 @@ defineProps({
$itemWidth: 86%; $itemWidth: 86%;
/* 内容高度 */ /* 内容高度 */
$centerHeight: 100px; $centerHeight: 100px;
.item-box { @include go('content-charts-item-box') {
.item-box {
margin: 0 7%; margin: 0 7%;
margin-bottom: 15px; margin-bottom: 15px;
width: $itemWidth; width: $itemWidth;
@ -70,5 +87,6 @@ $centerHeight: 100px;
@extend .go-transition; @extend .go-transition;
} }
} }
}
} }
</style> </style>