Collapse (折叠面版)
多种折叠模式,折叠面板组件适用于需要节省空间或按需展示信息的场景,如FAQ问答、用户设置选项、表单折叠区域等,能够提供清晰且结构化的用户界面。
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page main-class='p-30'>
<t-card main-class='mb-30' title="Collapse 折叠面板"
sub-title="多种折叠模式,折叠面板组件适用于需要节省空间或按需展示信息的场景,如FAQ问答、用户设置选项、表单折叠区域等,能够提供清晰且结构化的用户界面。"></t-card>
<t-card main-class='mb-30' title="提示" sub-title="小程序不支持UniResizeObserver API,折叠内容发生动态高度变化不会自动适应。需要手动调用updateChildHeight方法"></t-card>
<t-section title="基础使用+禁用展示+默认展示" main-class="tdr tdb mb-30"></t-section>
<t-collapse :values="['2','3']" main-class="tdr tdb mb-30 oh">
<template v-for="item in list" :key="item.id">
<t-collapse-item :title="item.title" :value="item.id.toString()" icon="map" label="测试"
:disabled="item.disabled">
<t-text main-class="s-28 slh-45 sls-5">
{{item.value}}
</t-text>
</t-collapse-item>
</template>
</t-collapse>
<t-section title="主题展示" main-class="tdr tdb mb-30"></t-section>
<t-collapse main-class="tdr mb-30 oh" type='s' effect="light" :border="true">
<template v-for="item in list" :key="item.id">
<t-collapse-item :title="item.title" label="标签" icon="map">
<t-text main-class="s-28 slh-45 sls-5" type="s">
{{item.value}}
</t-text>
</t-collapse-item>
</template>
</t-collapse>
<t-collapse main-class="tdr mb-30 oh" type='s'>
<template v-for="item in list" :key="item.id">
<t-collapse-item :title="item.title" label="标签" icon="map">
<t-text main-class="s-28 slh-45 sls-5 c-#fff">
{{item.value}}
</t-text>
</t-collapse-item>
</template>
</t-collapse>
<t-section title="禁用边框+手风琴模式" main-class="tdr tdb mb-30"></t-section>
<t-collapse :accordion="true" main-class="tdr tdb mb-30 oh">
<template v-for="item in list" :key="item.id">
<t-collapse-item :title="item.title" :border="false">
<t-text main-class="s-28 slh-45 sls-5">
{{item.value}}
</t-text>
</t-collapse-item>
</template>
</t-collapse>
<view style="height: 300px;"></view>
</t-page>
</template>
<script>
type collItem = {
title : string
id : number,
value : string
disabled : boolean
}
export default {
data() {
return {
list: [
{
title: '开发指南',
id: 1,
value: "基础组件满足基本开发需求,功能全面,跨平台兼容。助力快速开发,即插即用",
disabled: false
},
{
title: '使用手册(禁用)',
id: 2,
value: "进阶组件覆盖复杂场景,功能强大,兼容性佳。简化集成过程,无需额外配置",
disabled: true
},
{
title: '编程向导',
id: 3,
value: "高级组件应对特殊需求,高度定制,全平台支持。提高开发效率,一步到位",
disabled: false
},
{
title: '技术文档',
id: 4,
value: "核心组件助力项目核心功能,稳定可靠,多端适配。加速产品上线,省时省力",
disabled: false
},
{
title: 'API参考',
id: 5,
value: "工具组件丰富开发工具箱,灵活多变,易于集成。增强开发体验,便捷高效",
disabled: false
},
{
title: '教程指南',
id: 6,
value: "UI组件提升界面美观度,交互流畅,响应式设计。提升用户体验,美观大方",
disabled: false
},
{
title: '帮助文档',
id: 7,
value: "图表组件助力数据分析,直观展示,易于扩展。增强数据表现力,一目了然",
disabled: false
},
{
title: '快速入门',
id: 8,
value: "框架组件简化项目架构,模块化设计,易于维护。降低开发难度,快速上手",
disabled: false
}
] as collItem[]
};
}
}
</script>
属性
名称 | 类型 | 默认值 | 说明 | 可选值 |
---|---|---|---|---|
size | String | mini | 组件尺寸 | large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你) |
type | String | "" | 组件类型 | info(信息), primary(正常), error(错误), warning(警告), success(成功) |
disabled | Boolean | false | 组件是否禁用 | false, true |
stop | Boolean | false | 是否阻止事件冒泡(Tui统一写法处理事件冒泡) | false, true |
hover | Boolean | true | 是否有点击效果 | false, true |
path | String | "" | 点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。 | - |
mainClass | String | "" | 组件根节点的样式 | - |
nativeClass | String | "" | 组件根节点原生样式 | - |
effect | String | "normal" | 组件显示主题 | normal(正常), dark(深色), light(浅色), plain(镂空) |
border | Boolean | false | 是否显示边框 | |
borderClass | String | `` | 边框样式 | |
accordion | Boolean | false | 是否开启手风琴械 | |
values | string[] | [] | 默认展开的ID集合 | |
cellMainClass | String | `` | header头cell样式 | |
rowRightIconClass | String | `` | 统一设置子组件右侧力图标样式,如果子元素也设置样式则合并样式,优先级低于子组件 | |
rowTitleClass | String | `` | 统一设置子元素标题的样式, 如果子元素也设置样式则合并样式,优先级低于子组件 | |
rowIconClass | String | `` | 统一设置子元素图标的样式,如果子元素也设置样式则合并样式,优先级低于子组件 | |
rowContentClass | String | `` | 统一设置子元素右侧图标的样式 如果子元素也设置样式则合并样式,优先级低于子组件 | |
rowBoxClass | String | bgn | 统一设置子元素每一项的样式,如果子元素也设置样式则合并样式,优先级低于子组件 | |
rowHeaderBoxClass | String | bgn | 统一设置子元素 header盒子的样式 如果子元素也设置样式则合并样式,优先级低于子组件 | |
rowLabelClass | String | `` | 统一设置子元素标签的样式,如果子元素也设置样式则合并样式,优先级低于子组件 |
方法
名称 | 参数 | 返回值 | 说明 |
---|---|---|---|
updateChildHeight | - | - | 小程序无法使用UniResizeObserver有时候不会自动折叠高度,需要通过这个方法手动调整高度 |
插槽
名称 | 返回值 | 说明 |
---|---|---|
default | - |