Skip to content

feat(Tree): draggable property support function type(#8450)#8478

Open
xu-xiaoya wants to merge 1 commit intovueComponent:mainfrom
xu-xiaoya:feat/tree-draggable-function
Open

feat(Tree): draggable property support function type(#8450)#8478
xu-xiaoya wants to merge 1 commit intovueComponent:mainfrom
xu-xiaoya:feat/tree-draggable-function

Conversation

@xu-xiaoya
Copy link
Copy Markdown

@xu-xiaoya xu-xiaoya commented Feb 2, 2026

🔥 功能说明

为 Tree 组件的 draggable 属性添加函数类型支持,可实现基于节点数据的动态拖拽控制。

✨ 解决的问题

当前 draggable 只支持布尔值,无法根据节点数据动态控制拖拽状态。
Ant Design React 版本已支持此功能,Vue 版本缺失该功能。

📝 修改内容

1. 类型定义

  • ✅ 更新 draggable 属性类型:boolean | DraggableFn,vc已有 DraggableFn 类型:(node: EventDataNode) => boolean

2. 组件实现

  • ✅ 直接传递函数给底层 vc-tree
  • ✅ 保持向后兼容(布尔值完全支持)

3. 文档更新

  • ✅ 更新中英文 API 文档

4. 测试验证

  • 本地功能测试通过
  • TypeScript 类型检查通过
  • 向后兼容测试通过

🎯 使用示例

<template>
  <a-tree 
    :tree-data="treeData"
    :draggable="checkDraggable"
  />
</template>
<script setup>
const treeData = [
  { key: 'admin', title: '管理员', role: 'admin' },
  { key: 'user', title: '普通用户', role: 'user' },
];

const checkDraggable = (node) => {
  return node.role === 'admin'; // 仅管理员可拖拽
};
</script>

@xu-xiaoya xu-xiaoya changed the title feat(Tree): draggable property support function type feat(Tree): draggable property support function type(#8450) Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant