You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

title description spline isComponent
TreeSelect 树形选择 适用于选择树形的数据结构。 form true
该组件于 0.32.0 版本上线,请留意版本。

引入

全局引入,在 miniprogram 根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。

"usingComponents": {
  "t-tree-select": "tdesign-miniprogram/tree-select/tree-select"
}

代码演示

组件类型

基础树形选择

{{ base }}

多选树形选择

{{ multiple }}

组件状态

三级树形选择

{{ normal }}

API

TreeSelect Props

名称 类型 默认值 说明 必传
height String / Number 336 高度,默认单位为 px N
keys Object - 用来定义 value / label 在 options 中对应的字段别名。TS 类型:KeysType N
multiple Boolean false 是否多选 N
options Array [] 选项。TS 类型:Array<DataOption> N
value String / Number / Array - 选中值。TS 类型:TreeSelectValue type TreeSelectValue = string | number | Array<TreeSelectValue>详细类型定义 N
default-value String / Number / Array undefined 选中值。非受控属性。TS 类型:TreeSelectValue type TreeSelectValue = string | number | Array<TreeSelectValue>详细类型定义 N

TreeSelect Events

名称 参数 描述
change (value: TreeSelectValue, level: TreeLevel) 点击任何节点均会触发level 代表当前点击的层级0 代表最左侧,依次递进。详细类型定义
type TreeLevel: 0 | 1 | 2