Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@hi-ui/cascader

Package Overview
Dependencies
Maintainers
2
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hi-ui/cascader

A sub-package for @hi-ui/hiui.

latest
Source
npmnpm
Version
4.5.0
Version published
Weekly downloads
336
156.49%
Maintainers
2
Weekly downloads
 
Created
Source

Cascader 级联选择

一种接收数据的容器,为用户提供选择一部分数据的能力

何时使用

需要从大量的离散型数据中选择一部分时使用

备选项数量 5 个以上时

不需要将全部备选项都展示给用户时

使用示例

Props

参数说明类型可选值默认值
disabled是否禁止使用booleantrue | falsefalse
placeholder输入框占位string-'请选择'
searchPlaceholder搜索输入框占位string-'搜索'
emptyContent设置选项为空时展示的内容ReactNode-'无匹配数据'
loadingContent设置加载中时展示的内容ReactNode-'数据加载中...'
overlayClassName下拉根元素的类名称string--
searchable是否可搜索booleantrue | falsefalse
clearable是否可清空booleantrue | falsetrue
overlay自定义控制弹出层 popper 行为PopperOverlayProps--
fieldNames设置 data 中 label, value, children 对应的 keyobject-{ label: 'label', value: 'value', children: 'children'}
data设置选择项数据源CascaderDataItem[]--
value设置当前选中值ReactText[]-[]
defaultValue设置当前选中值默认值ReactText[]-[]
displayRender自定义选择后展示的内容(value: string[]) => string--
expandTrigger次级菜单的展开方式,可选 'click' 和 'hover'string'click' | 'hover''click'
filterOption第一个参数为输入的关键字,第二个为数据项,返回值为 true 时将出现在结果项。仅在 searchable 为 true 时有效(keyword: string, item: DataItem) => boolean--
changeOnSelect是否启用选择即改变功能booleantrue | falsefalse
flatted将选项拍平展示,不支持 onLoadChildren 异步加载交互true | falsefalse
upMatch开启全量搜索,默认只对开启对可选的选项进行搜索,不向上查找路径true | falsefalse
render自定义渲染节点的 title 内容径(item: CascaderItemEventData) => React.ReactNode-
filterOption自定义搜索过滤器,仅在 searchable 为 true 时有效。第一个参数为输入的关键字,第二个为数据项,返回值为 true 时将出现在结果项(keyword: string, item: CascaderItemEventData) => boolean-
appearance设置展现形式'line' | 'unset' | 'filled''line'

Events

名称说明类型参数返回值
onChange选择后的回调(values: ReactText[]) => voidvalues: 选中项集合-
onActiveItemChange选中项改变时的回调(values: string[]) => voidvalues: 选中项集合-
onOpen下拉菜单打开时回调() => void--
onClose下拉菜单关闭时回调() => void--
onLoadChildren异步请求更新数据(item: CascaderItemEventData) => Promise<CascaderItem[] | void> | void--

Type

CascaderDataItem

参数说明类型可选值默认值
id下拉选择项唯一值ReactText--
title下拉选择项标题string--
disabled是否禁用booleantrue | falsefalse

CascaderItemEventData

参数说明类型可选值默认值
id选择项值string--
title选择项string--
disabled是否禁用booleantrue | falsefalse
depth选项的层级,根节点层级为 0number--
raw原始数据,包括约定模型之外的数据object--
parent选项的父级节点数据object--
children选项的孩子节点列表数据object[]--
selected节点是否被选中booleantrue | false-
loading节点是否在异步加载子项数据中booleantrue | false-

DataSource

继承 Axios 的 api

参数说明类型可选值默认值
url请求的 urlstring--
method请求方法stringget | postget
datapost 请求时请求体参数object--
paramsurl 查询参数object--
headers请求头object--
withCredentials上传请求时是否携带 cookiebooleantrue | falsefalse
transformResponse成功时的回调,用于对数据进行预处理(response: object) => DataItem[]--
error请求发生异常的回调方法(error: object) => void--

CHANGELOG

参数变更类型变更内容解决的问题
propNamefeature | deprecated | update变更了什么之前是什么样子,解决什么问题
----------------
valueupdate类型 string[] => string[] | number[]对于表单控件 id 值的控制,均使用 React.ReactText(即 string 和 number 都支持)
defaultValueupdate类型 string[] => string[] | number[]对于表单控件 id 值的控制,均使用 React.ReactText(即 string 和 number 都支持)
idupdate类型 string => string | number对于表单控件 id 值的控制,均使用 React.ReactText(即 string 和 number 都支持)
bordereddeprecated字段 bordered => appearance对于 Picker 类型的组件,统一使用 appearance 设置外形(线\面\无边框)值
contentdeprecated字段 content => title对于 DataItem 模型数据,统一使用 title
searchPlaceholderfeature-Picker 类型组件统一支持
loadingContentfeature-Picker 类型组件统一支持,适配新 UI
overlayfeature-Picker 类型组件统一支持,聚合管理。比如: placement,之前有的加了有的没加
onLoadChildrenfeature-树形数据懒加载统一方案,并强化返回值 Promise 功能,保持一致,替代 onActiveItemChange
onActiveItemChangedeprecated-使用 onLoadChildren 替代
renderfeature(item: CascaderItemEventData) => React.ReactNode统一支持自定义渲染每一项
filterOptionfeature(keyword: string, item: CascaderItemEventData) => boolean统一支持自定义过滤
appearancefeature'line' | 'unset' | 'filled'统一支持:线性\面性\无边框
displayRenderfeature(value: string[]) => string -> (item: CascaderItemEventData, items: CascaderItemEventData[]) => React.ReactNode支持自定义节点渲染

FAQs

Package last updated on 08 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts