From acc60d3266cdbaa2787bf6da6396ee571e8fc643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Thu, 14 Feb 2019 20:10:00 +0800 Subject: [PATCH] [improvement] Collapse: scopedSlots --- packages/collapse-item/index.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/collapse-item/index.js b/packages/collapse-item/index.js index 208e828df..3b93c95a8 100644 --- a/packages/collapse-item/index.js +++ b/packages/collapse-item/index.js @@ -96,7 +96,10 @@ export default sfc({ } const { parent } = this; - const name = parent.accordion && this.currentName === parent.value ? '' : this.currentName; + const name = + parent.accordion && this.currentName === parent.value + ? '' + : this.currentName; const expanded = !this.expanded; this.parent.switch(name, expanded); }, @@ -111,15 +114,28 @@ export default sfc({ }, render(h) { + const titleSlots = CELL_SLOTS.reduce( + (slots, name) => { + if (this.slots(name)) { + slots[name] = () => this.slots(name); + } + return slots; + }, + { + default: () => this.slots('value') + } + ); + const Title = ( - {this.slots('value')} - {CELL_SLOTS.map(slot => h('template', { slot }, this.slots(slot)))} - + /> ); const Content = this.inited && (