diff --git a/components.js b/components.js
index 3cf7e5e4e..ef067b29d 100644
--- a/components.js
+++ b/components.js
@@ -60,4 +60,6 @@ module.exports = [
'dropdown-menu',
'dropdown-item',
'notify',
+ 'collapse',
+ 'collapse-item',
];
diff --git a/src/collapse-item/index.js b/src/collapse-item/index.js
index 25826cde8..d40a495b5 100644
--- a/src/collapse-item/index.js
+++ b/src/collapse-item/index.js
@@ -11,8 +11,6 @@ import { cellProps } from '../cell/shared';
const [createComponent, bem] = createNamespace('collapse-item');
-const CELL_SLOTS = ['title', 'icon', 'right-icon'];
-
export default createComponent({
mixins: [ChildrenMixin('vanCollapse')],
@@ -43,20 +41,22 @@ export default createComponent({
return null;
}
- const { value, accordion } = this.parent;
+ const { modelValue, accordion } = this.parent;
if (
process.env.NODE_ENV !== 'production' &&
!accordion &&
- !Array.isArray(value)
+ !Array.isArray(modelValue)
) {
- console.error('[Vant] Collapse: type of prop "value" should be Array');
+ console.error(
+ '[Vant] Collapse: type of prop "modelValue" should be Array'
+ );
return;
}
return accordion
- ? value === this.currentName
- : value.some((name) => name === this.currentName);
+ ? modelValue === this.currentName
+ : modelValue.some((name) => name === this.currentName);
},
},
@@ -110,7 +110,7 @@ export default createComponent({
}
const { parent, currentName } = this;
- const close = parent.accordion && currentName === parent.value;
+ const close = parent.accordion && currentName === parent.modelValue;
const name = close ? '' : currentName;
parent.switch(name, !this.expanded);
@@ -127,27 +127,22 @@ export default createComponent({
genTitle() {
const { border, disabled, expanded } = this;
- const titleSlots = CELL_SLOTS.reduce((slots, name) => {
- if (this.slots(name)) {
- slots[name] = () => this.slots(name);
- }
-
- return slots;
- }, {});
-
- if (this.slots('value')) {
- titleSlots.default = () => this.slots('value');
- }
+ const slots = {
+ icon: this.$slots.icon,
+ title: this.$slots.title,
+ default: this.$slots.value,
+ 'right-icon': this.$slots['right-icon'],
+ };
return (