Skip to content

AtComplexSelector

夏源庆
最后更新于 2025-11-18 14:57:11

简单的复杂选择器

Warning

该组件使用了 useMessage , 请检查组件是否放在 n-message-provider 内部使用

代码演示

基础用法

限制最大数量

配置 maxLimit 限制最大选择数量, 结合 showCountselectedCount 来控制显示当前选择数量与最大选择数量

可过滤的

通过配置 filterable 来开启过滤, 配合 filter 使用自定义过滤器

异步加载数据

通过配置 remote 来开启异步加载, 配合 on-load 回调来加载数据。

Tip

异步加载时,所有 isLeaffalse 并且 children 不为数组的节点会被视为需要加载的节点。

API

AtComplexSelector Props

名称类型默认值说明版本
value arrayundefined受控的选中值
optionsarray[]原始树形数据
show-countbooleanfalse是否显示已选数量
selected-count numberundefined受控的已选择数量
max-limitnumber0限制最大可选数量
check-strictlybooleanfalse严格选中(父子节点选中状态不再关联)
group-avatarstringundefined默认组头像
user-avatarstringundefined默认用户头像
label-fieldstringlabel替代 AtComplexSelectorOption 中的 label 字段名
value-fieldstringvalue替代 AtComplexSelectorOption 中的 value 字段名
children-fieldstringchildren替代 AtComplexSelectorOption 中的 children 字段名
filterablebooleanfalse是否可过滤
selector-classstringundefined左侧selector的类名
selector-styleobjectundefined左侧selector的style
filterfunction一个简单的字符串搜索算法过滤器函数
remotebooleanfalse是否支持异步加载, 在异步的状况下你可能需要把它设为 true
on-loadPromiseundefined异步加载数据
on-changefunctionundefined改变回调
on-checked-allfunctionundefined选择全部回调

AtComplexSelectorOption Properties

名称类型描述版本
labelstringlabel 标签,用于展示信息
valuestring | number对应 label 的 value 值
disabled?boolean该项是否禁用
avatar?string指定头像图片链接
children?AtComplexSelectorOption该项的子项数据, 详情查看类型声明

AtComplexSelectorAsyncOption Properties

名称类型描述版本
is-leaf?boolean是否为叶子

AtComplexSelector Events

名称参数说明版本
change(checked: boolean, option: AtComplexSelectorProps['options'][number])选项选中状态改变时触发
checked-all(checked: boolean, options: AtComplexSelectorProps['options'])全选/取消全选时触发

AtComplexSelector Expose

名称类型说明版本
get-selected-nodesfunction获取选中的数据
manual-nextfunction手动下一页

类型声明

显示类型声明
Typescript
export interface AtComplexSelectorOption {
  [key: string]: any
  label: string
  value: string | number
  disabled?: boolean
  avatar?: string
  children?: AtComplexSelectorOption[]
}

/** 异步选项类型 */
export interface AtComplexSelectorAsyncOption extends AtComplexSelectorOption {
  isLeaf?: boolean
}

changelog

5452f - feat(components): 支持自定义class and style 透传 on 2025/1/15
4f173 - feat(components): support manualNext on 2025/1/14
f1389 - feat(components): support getSelectedNodes function on 2024/12/30
4dd9d - fix(components): ignore ts error on 2024/12/23
2a4f1 - fix(AtComplexSelector): add ignore-item-resize for vl on 2024/12/3
18669 - fix(AtComplexSelector): add NEL container on 2024/11/29
77b44 - fix(AtComplexSelector): remove themeVars on 2024/11/29
c9db5 - fix(AtComplexSelector): memo themeVars try third on 2024/11/29
6b951 - fix(AtComplexSelector): memo themeVars try again on 2024/11/29
a568a - fix(AtComplexSelector): memo themeVars on 2024/11/29

贡献者

Last updated: