vxe-tree 如何将一个节点拖拽到一个没有子级的节点下
vxe-tree 如何将一个节点拖拽到一个没有子级的节点下,通过 drag-config.isToChildDrag 启用便捷拖拽成子节点,拖拽的同时按住 Ctrl 键可以自动拖放到该节点的子级
官网:https://vxeui.com
github:https://github.com/x-extends/vxe-pc-ui
gitee:https://gitee.com/x-extends/vxe-pc-ui
效果
通过 drag-config.isToChildDrag 启用,使用方式非常简单,拖拽的同时按住 Ctrl 键就可以将当前节点拖拽的目标节点的下面

<template>
<div>
<vxe-tree v-bind="treeOptions"></vxe-tree>
</div>
</template>
<script setup>
import { reactive } from 'vue'
const treeOptions = reactive({
transform: true,
drag: true,
dragConfig: {
isCrossDrag: true,
isSelfToChildDrag: true,
isToChildDrag: true
},
data: [
{ title: '节点2', id: '2', parentId: null },
{ title: '节点3', id: '3', parentId: null },
{ title: '节点3-1', id: '31', parentId: '3' },
{ title: '节点3-2', id: '32', parentId: '3' },
{ title: '节点3-2-1', id: '321', parentId: '32' },
{ title: '节点3-2-2', id: '322', parentId: '32' },
{ title: '节点3-3', id: '33', parentId: '3' },
{ title: '节点3-3-1', id: '331', parentId: '33' },
{ title: '节点3-3-2', id: '332', parentId: '33' },
{ title: '节点3-3-3', id: '333', parentId: '33' },
{ title: '节点3-4', id: '34', parentId: '3' },
{ title: '节点4', id: '4', parentId: null },
{ title: '节点4-1', id: '41', parentId: '4' },
{ title: '节点4-1-1', id: '411', parentId: '42' },
{ title: '节点4-1-2', id: '412', parentId: '42' },
{ title: '节点4-2', id: '42', parentId: '4' },
{ title: '节点4-3', id: '43', parentId: '4' },
{ title: '节点4-3-1', id: '431', parentId: '43' },
{ title: '节点4-3-2', id: '432', parentId: '43' },
{ title: '节点5', id: '5', parentId: null }
]
})
</script>

浙公网安备 33010602011771号