title: TreeSelect 树形选择 description: 适用于选择树形的数据结构。 spline: form
全局引入,在 miniprogram 根目录下的app.json
中配置,局部引入,在需要引入的页面或组件的index.json
中配置。
"usingComponents": {
"t-tree-select": "tdesign-miniprogram/tree-select/tree-select"
}
Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"
{{ base }}
{{ multiple }}
{{ normal }}
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
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
名称 | 参数 | 描述
-- | -- | --
change | (value: TreeSelectValue, level: TreeLevel)
| 点击任何节点均会触发;level 代表当前点击的层级,0 代表最左侧,依次递进。详细类型定义。type TreeLevel = 0 \| 1 \| 2
类名 | 描述 -- | -- t-class | 根节点样式类 t-class-left-column | 左侧第一列样式类 t-class-left-item | 左侧第一列子项样式类 t-class-middle-item | 中间列子项样式类 t-class-right-column | 右侧第一列样式类 t-class-right-item | 右侧第一列子项样式类 t-class-right-item-label | 右侧第一列子项标签样式类
组件提供了下列 CSS 变量,可用于自定义样式。 名称 | 默认值 | 描述 -- | -- | -- --td-tree-bg-color | @bg-color-container | - --td-tree-colum-width | 206rpx | - --td-tree-item-active-color | @brand-color | - --td-tree-item-font-size | 32rpx | - --td-tree-item-height | 112rpx | - --td-tree-root-bg-color | @bg-color-secondarycontainer | -