/*! For license information please see 3460.1d6da2b5.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["3460"],{33031:function(s,a,n){"use strict";n.r(a);var t=n("80681");let l=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

Collapse \u6298\u53E0\u9762\u677F

\n

\u4ECB\u7ECD

\n

\u5C06\u4E00\u7EC4\u5185\u5BB9\u653E\u7F6E\u5728\u591A\u4E2A\u6298\u53E0\u9762\u677F\u4E2D\uFF0C\u70B9\u51FB\u9762\u677F\u7684\u6807\u9898\u53EF\u4EE5\u5C55\u5F00\u6216\u6536\u7F29\u5176\u5185\u5BB9\u3002

\n

\u5F15\u5165

\n

\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002

\n
import { createApp } from 'vue';\nimport { Collapse, CollapseItem } from 'vant';\n\nconst app = createApp();\napp.use(Collapse);\napp.use(CollapseItem);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

\u901A\u8FC7 v-model \u63A7\u5236\u5C55\u5F00\u7684\u9762\u677F\u5217\u8868\uFF0CactiveNames \u4E3A\u6570\u7EC4\u683C\u5F0F\u3002

\n
<van-collapse v-model="activeNames">\n  <van-collapse-item title="\u6807\u98981" name="1">\n    \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98982" name="2">\n    \u6280\u672F\u65E0\u975E\u5C31\u662F\u90A3\u4E9B\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98983" name="3">\n    \u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002\n  </van-collapse-item>\n</van-collapse>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const activeNames = ref(['1']);\n    return { activeNames };\n  },\n};\n
\n

\u624B\u98CE\u7434

\n

\u901A\u8FC7 accordion \u53EF\u4EE5\u8BBE\u7F6E\u4E3A\u624B\u98CE\u7434\u6A21\u5F0F\uFF0C\u6700\u591A\u5C55\u5F00\u4E00\u4E2A\u9762\u677F\uFF0C\u6B64\u65F6 activeName \u4E3A\u5B57\u7B26\u4E32\u683C\u5F0F\u3002

\n
<van-collapse v-model="activeName" accordion>\n  <van-collapse-item title="\u6807\u98981" name="1">\n    \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98982" name="2">\n    \u6280\u672F\u65E0\u975E\u5C31\u662F\u90A3\u4E9B\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98983" name="3">\n    \u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002\n  </van-collapse-item>\n</van-collapse>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const activeName = ref('1');\n    return { activeName };\n  },\n};\n
\n

\u7981\u7528\u72B6\u6001

\n

\u901A\u8FC7 disabled \u5C5E\u6027\u6765\u7981\u7528\u5355\u4E2A\u9762\u677F\u3002

\n
<van-collapse v-model="activeNames">\n  <van-collapse-item title="\u6807\u98981" name="1">\n    \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98982" name="2" disabled>\n    \u6280\u672F\u65E0\u975E\u5C31\u662F\u90A3\u4E9B\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98983" name="3" disabled>\n    \u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002\n  </van-collapse-item>\n</van-collapse>\n
\n

\u81EA\u5B9A\u4E49\u6807\u9898\u5185\u5BB9

\n

\u901A\u8FC7 title \u63D2\u69FD\u53EF\u4EE5\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u7684\u5185\u5BB9\u3002

\n
<van-collapse v-model="activeNames">\n  <van-collapse-item name="1">\n    <template #title>\n      <div>\u6807\u98981 <van-icon name="question-o" /></div>\n    </template>\n    \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98982" name="2" icon="shop-o">\n    \u6280\u672F\u65E0\u975E\u5C31\u662F\u90A3\u4E9B\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002\n  </van-collapse-item>\n</van-collapse>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const activeNames = ref(['1']);\n    return { activeNames };\n  },\n};\n
\n

\u5168\u90E8\u5C55\u5F00\u4E0E\u5168\u90E8\u5207\u6362

\n

\u901A\u8FC7 Collapse \u5B9E\u4F8B\u4E0A\u7684 toggleAll \u65B9\u6CD5\u53EF\u4EE5\u5B9E\u73B0\u5168\u90E8\u5C55\u5F00\u4E0E\u5168\u90E8\u5207\u6362\u3002

\n
<van-collapse v-model="activeNames" ref="collapse">\n  <van-collapse-item title="\u6807\u98981" name="1">\n    \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98982" name="2">\n    \u6280\u672F\u65E0\u975E\u5C31\u662F\u90A3\u4E9B\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002\n  </van-collapse-item>\n  <van-collapse-item title="\u6807\u98983" name="3">\n    \u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002\n  </van-collapse-item>\n</van-collapse>\n\n<van-button type="primary" @click="openAll">\u5168\u90E8\u5C55\u5F00</van-button>\n<van-button type="primary" @click="toggleAll">\u5168\u90E8\u5207\u6362</van-button>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const activeNames = ref(['1']);\n    const collapse = ref(null);\n\n    const openAll = () => {\n      collapse.value.toggleAll(true);\n    }\n    const toggleAll = () => {\n      collapse.value.toggleAll();\n    },\n\n    return {\n      activeNames,\n      openAll,\n      toggleAll,\n      collapse,\n    };\n  },\n};\n
\n
\n

Tips: \u624B\u98CE\u7434\u6A21\u5F0F\u4E0B\u65E0\u6CD5\u4F7F\u7528 toggleAll \u65B9\u6CD5\u3002

\n
\n

API

\n

Collapse Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
v-model\u5F53\u524D\u5C55\u5F00\u9762\u677F\u7684 name\u624B\u98CE\u7434\u6A21\u5F0F\uFF1Anumber | string
\u975E\u624B\u98CE\u7434\u6A21\u5F0F\uFF1A(number | string)[]
-
accordion\u662F\u5426\u5F00\u542F\u624B\u98CE\u7434\u6A21\u5F0Fbooleanfalse
border\u662F\u5426\u663E\u793A\u5916\u8FB9\u6846booleantrue
\n

Collapse Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
change\u5207\u6362\u9762\u677F\u65F6\u89E6\u53D1activeNames: \u7C7B\u578B\u4E0E v-model \u7ED1\u5B9A\u7684\u503C\u4E00\u81F4
\n

CollapseItem Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
name\u552F\u4E00\u6807\u8BC6\u7B26\uFF0C\u9ED8\u8BA4\u4E3A\u7D22\u5F15\u503Cnumber | stringindex
icon\u6807\u9898\u680F\u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027string-
size\u6807\u9898\u680F\u5927\u5C0F\uFF0C\u53EF\u9009\u503C\u4E3A largestring-
title\u6807\u9898\u680F\u5DE6\u4FA7\u5185\u5BB9number | string-
value\u6807\u9898\u680F\u53F3\u4FA7\u5185\u5BB9number | string-
label\u6807\u9898\u680F\u63CF\u8FF0\u4FE1\u606Fnumber | string-
border\u662F\u5426\u663E\u793A\u5185\u8FB9\u6846booleantrue
is-link\u662F\u5426\u5C55\u793A\u6807\u9898\u680F\u53F3\u4FA7\u7BAD\u5934\u5E76\u5F00\u542F\u70B9\u51FB\u53CD\u9988booleantrue
disabled\u662F\u5426\u7981\u7528\u9762\u677Fbooleanfalse
readonly\u662F\u5426\u4E3A\u53EA\u8BFB\u72B6\u6001\uFF0C\u53EA\u8BFB\u72B6\u6001\u4E0B\u65E0\u6CD5\u64CD\u4F5C\u9762\u677Fbooleanfalse
lazy-render\u662F\u5426\u5728\u9996\u6B21\u5C55\u5F00\u65F6\u624D\u6E32\u67D3\u9762\u677F\u5185\u5BB9booleantrue
title-class\u5DE6\u4FA7\u6807\u9898\u989D\u5916\u7C7B\u540Dstring-
value-class\u53F3\u4FA7\u5185\u5BB9\u989D\u5916\u7C7B\u540Dstring-
label-class\u63CF\u8FF0\u4FE1\u606F\u989D\u5916\u7C7B\u540Dstring-
\n

Collapse \u65B9\u6CD5

\n

\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 CollapseItem \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u65B9\u6CD5\u540D\u8BF4\u660E\u53C2\u6570\u8FD4\u56DE\u503C
toggleAll\u5207\u6362\u6240\u6709\u9762\u677F\u5C55\u5F00\u72B6\u6001\uFF0C\u4F20 true \u4E3A\u5168\u90E8\u5C55\u5F00\uFF0Cfalse \u4E3A\u5168\u90E8\u6536\u8D77\uFF0C\u4E0D\u4F20\u53C2\u4E3A\u5168\u90E8\u5207\u6362options?: boolean | object-
\n

toggleAll \u65B9\u6CD5\u793A\u4F8B

\n
import { ref } from 'vue';\nimport type { CollapseInstance } from 'vant';\n\nconst collapseRef = ref<CollapseInstance>();\n\n// \u5168\u90E8\u5207\u6362\ncollapseRef.value?.toggleAll();\n// \u5168\u90E8\u5C55\u5F00\ncollapseRef.value?.toggleAll(true);\n// \u5168\u90E8\u6536\u8D77\ncollapseRef.value?.toggleAll(false);\n\n// \u5168\u90E8\u5168\u90E8\u5207\u6362\uFF0C\u5E76\u8DF3\u8FC7\u7981\u7528\u7684\u590D\u9009\u6846\ncollapseRef.value?.toggleAll({\n  skipDisabled: true,\n});\n// \u5168\u90E8\u9009\u4E2D\uFF0C\u5E76\u8DF3\u8FC7\u7981\u7528\u7684\u590D\u9009\u6846\ncollapseRef.value?.toggleAll({\n  expanded: true,\n  skipDisabled: true,\n});\n
\n

CollapseItem \u65B9\u6CD5

\n

\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 CollapseItem \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u65B9\u6CD5\u540D\u8BF4\u660E\u53C2\u6570\u8FD4\u56DE\u503C
toggle\u5207\u6362\u9762\u677F\u5C55\u5F00\u72B6\u6001\uFF0C\u4F20 true \u4E3A\u5C55\u5F00\uFF0Cfalse \u4E3A\u6536\u8D77\uFF0C\u4E0D\u4F20\u53C2\u4E3A\u5207\u6362expand?: boolean-
\n

\u7C7B\u578B\u5B9A\u4E49

\n

\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A

\n
import type {\n  CollapseProps,\n  CollapseItemProps,\n  CollapseItemInstance,\n  CollapseToggleAllOptions,\n} from 'vant';\n
\n

CollapseItemInstance \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A

\n
import { ref } from 'vue';\nimport type { CollapseItemInstance } from 'vant';\n\nconst collapseItemRef = ref<CollapseItemInstance>();\n\ncollapseItemRef.value?.toggle();\n
\n

CollapseItem Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E
default\u9762\u677F\u5185\u5BB9
title\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u5DE6\u4FA7\u5185\u5BB9
value\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u53F3\u4FA7\u5185\u5BB9
label\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u63CF\u8FF0\u4FE1\u606F
icon\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u5DE6\u4FA7\u56FE\u6807
right-icon\u81EA\u5B9A\u4E49\u6807\u9898\u680F\u53F3\u4FA7\u56FE\u6807
\n

\u4E3B\u9898\u5B9A\u5236

\n

\u6837\u5F0F\u53D8\u91CF

\n

\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 ConfigProvider \u7EC4\u4EF6\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u9ED8\u8BA4\u503C\u63CF\u8FF0
--van-collapse-item-durationvar(--van-duration-base)-
--van-collapse-item-content-paddingvar(--van-padding-sm) var(--van-padding-md)-
--van-collapse-item-content-font-sizevar(--van-font-size-md)-
--van-collapse-item-content-line-height1.5-
--van-collapse-item-content-text-colorvar(--van-text-color-2)-
--van-collapse-item-content-backgroundvar(--van-background-2)-
--van-collapse-item-title-disabled-colorvar(--van-text-color-3)-
\n
'},null,8,l))}}}]);