Skip to content

Collapse 折叠面板

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

基础用法

可同时展开多个面板,面板之间不影响

Title A

headline title

Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.
Title B
Disabled Title
<script setup>
import { ref } from "vue";
import KCollapse from "@/components/Collapse/Collapse.vue";
import KCollapseItem from "@/components/Collapse/CollapseItem.vue";
const openedValue = ref(["a"]);
</script>
<template>
  <div class="ma-4">
    <k-collapse v-model="openedValue">
      <k-collapse-item name="a" title="Title A">
        <h1>headline title</h1>
        <div>
          Consistent within interface: all elements should be consistent, such
          as: design style, icons and texts, position of elements, etc.
        </div>
      </k-collapse-item>
      <k-collapse-item name="b" title="Title B">
        <div>
          Operation feedback: enable the users to clearly perceive their
          operations by style updates and interactive effects;
        </div>
        <div>
          Visual feedback: reflect current state by updating or rearranging
          elements of the page.
        </div>
      </k-collapse-item>
      <k-collapse-item name="c" title="Disabled Title" disabled>
        <div>
          Simplify the process: keep operating process simple and intuitive;
        </div>
        <div>
          Definite and clear: enunciate your intentions clearly so that the
          users can quickly understand and make decisions;
        </div>
        <div>
          Easy to identify: the interface should be straightforward, which helps
          the users to identify and frees them from memorizing and recalling.
        </div>
      </k-collapse-item>
    </k-collapse>
  </div>
</template>

手风琴效果

每次只能展开一个面板

通过 accordion 属性来设置是否以手风琴模式显示。

Consistency
Consistent with real life: in line with the process and logic of real life, and comply with languages and habits that the users are used to;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.
Feedback
Efficiency
<script lang="ts" setup>
import { ref } from "vue";
import KCollapse from "@/components/Collapse/Collapse.vue";
import KCollapseItem from "@/components/Collapse/CollapseItem.vue";
const activeName = ref(["a"]);
</script>

<template>
  <div>
    <k-collapse v-model="activeName" accordion>
      <k-collapse-item title="Consistency" name="a">
        <div>
          Consistent with real life: in line with the process and logic of real
          life, and comply with languages and habits that the users are used to;
        </div>
        <div>
          Consistent within interface: all elements should be consistent, such
          as: design style, icons and texts, position of elements, etc.
        </div>
      </k-collapse-item>
      <k-collapse-item title="Feedback" name="b">
        <div>
          Operation feedback: enable the users to clearly perceive their
          operations by style updates and interactive effects;
        </div>
        <div>
          Visual feedback: reflect current state by updating or rearranging
          elements of the page.
        </div>
      </k-collapse-item>
      <k-collapse-item title="Efficiency" name="c">
        <div>
          Simplify the process: keep operating process simple and intuitive;
        </div>
        <div>
          Definite and clear: enunciate your intentions clearly so that the
          users can quickly understand and make decisions;
        </div>
        <div>
          Easy to identify: the interface should be straightforward, which helps
          the users to identify and frees them from memorizing and recalling.
        </div>
      </k-collapse-item>
    </k-collapse>
  </div>
</template>

Collapse Attributes

属性名详情类型默认值
model-value/v-model当前活动面板,在手风琴模式下其类型是 string,在其他模式下是 arraystring/ array
accordion是否手风琴模式booleanboolean

Collapse Events

事件名说明类型
change切换当前活动面板,在手风琴模式下其类型是 string,在其他模式下是 arrayFunction

Collapse Slots

插槽名Description子标签
default自定义默认内容Collapse Item

Collapse Item API#

Collapse Item Attributes

属性名说明类型默认值
name唯一标志符string/ number
title面板标题string''
disabled是否禁用booleanfalse

Collapse Item Slot

插槽名说明
defaultCollapse Item 的内容
titleCollapse Item 的标题