如何实现 vxe-tree 树组件拖拽节点后进行二次确认提示

如何实现 vxe-tree 树组件拖拽节点后进行二次确认提示,参数 drag-config.dragStartMethod 可以自定义处理拖拽开始时的拖动,可以自定义是否允许拖拽

官网:vxeui.com github:github.com/x-extends/v... gitee:gitee.com/x-extends/v...

需要提示操作时,通过 drag-config.dragEndMethod 可以自定义处理拖拽结束时的拖动

html 复制代码
<template>
  <div>
    <vxe-tree v-bind="treeOptions"></vxe-tree>
  </div>
</template>

<script setup>
import { reactive } from 'vue'
import { VxeUI } from 'vxe-pc-ui'

const treeOptions = reactive({
  transform: true,
  drag: true,
  dragConfig: {
    isCrossDrag: true,
    isSelfToChildDrag: true,
    showGuidesStatus: true,
    async dragEndMethod () {
      const type = await VxeUI.modal.confirm({
        content: '请是否确认调整顺序?'
      })
      if (type === 'confirm') {
        return true
      }
      VxeUI.modal.message({
        content: '操作已取消',
        status: 'warning'
      })
      return false
    }
  },
  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>

gitee.com/x-extends/v...

相关推荐
VX:Fegn08954 小时前
计算机毕业设计|基于springboot + vue音乐管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·课程设计
涔溪4 小时前
微前端中History模式的路由拦截和传统前端路由拦截有什么区别?
前端·vue.js
涔溪6 小时前
微前端中 History 模式的路由拦截的优缺点是什么?
前端·vue.js
狗哥哥6 小时前
Vue 3 页面缓存机制深度实践:从原理到落地
前端·vue.js·架构
用户841794814566 小时前
vxe-table如何实现可编辑下拉框限制唯一选择,就是每一行选择一个选项后,其他行将不可再次选择该选择
vue.js
狗哥哥6 小时前
Vite 插件开发实战:从业务痛点到优雅解决方案
vue.js·架构·前端框架
老华带你飞6 小时前
在线学习平台|基于Java 在线学习管理平台系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·学习
好奇的候选人面向对象7 小时前
Vue3 + Element Plus 动态表格高度自适应方案详解
javascript·vue.js·elementui
+VX:Fegn08957 小时前
计算机毕业设计|基于springboot + vue超市管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计