Skip to content

Collapse 折叠面板

通过折叠面板收纳内容区域

基础用法

使用 typeplainroundcircle 来定义按钮的样式。

Title A

headline title

this is content a aaa
Title B
Disabled Title
<script setup>
import { ref } from 'vue';
import Collapse from '@/components/Collapse/Collapse.vue';
import Item from '@/components/Collapse/CollapseItem.vue';
const openedValue = ref(['a']);
</script>
<template>
    <div class="basic block">
        <Collapse v-model="openedValue">
            <Item name="a" title="Title A">
                <h1>headline title</h1>
                <div> this is content a aaa </div>
            </Item>
            <Item name="b" title="Title B">
                <div> this is bbbbb test </div>
            </Item>
            <Item name="c" title="Disabled Title" disabled>
                <div> this is cccc test </div>
            </Item>
        </Collapse>
    </div>
</template>

手风琴效果

每次只能展开一个面板 通过 accordion 属性来设置是否以手风琴模式显示。

Title A

headline title

this is content a aaa
Title B
Title C
<script setup>
import { ref } from 'vue';
import Collapse from '@/components/Collapse/Collapse.vue';
import Item from '@/components/Collapse/CollapseItem.vue';
const openedValue = ref('a');
</script>
<template>
    <div class="basic block">
        <Collapse v-model="openedValue" accordion>
            <Item name="a" title="Title A">
                <h1>headline title</h1>
                <div> this is content a aaa </div>
            </Item>
            <Item name="b" title="Title B">
                <div> this is bbbbb test </div>
            </Item>
            <Item name="c" title="Title C">
                <div> this is cccc test </div>
            </Item>
        </Collapse>
    </div>
</template>

Collapse Attributes

NameDescriptionTypeAccepted ValuesDefault
model-value / v-modelcurrently active panelstring (accordion mode) / array (non-accordion mode)
accordionwhether to activate accordion modebooleanfalse

Collapse Events

NameDescriptionParameters
changetriggers when active panels change(activeNames: array (non-accordion mode) / string (accordion mode))

Collapse Slots

NameDescriptionSubtags
-customize default contentCollapse Item

Collapse Item Attributes

NameDescriptionTypeAccepted ValuesDefault
nameunique identification of the panelstring/number
titletitle of the panelstring
disableddisable the collapse itemboolean

Collapse Item Slot

NameDescription
content of Collapse Item
titlecontent of Collapse Item title