fix: collapse controller mode

pull/2682/head
tanjinzhou 2020-07-28 16:31:13 +08:00
parent 777d1d5dda
commit ed3c4edf72
5 changed files with 13 additions and 4 deletions

@ -1 +1 @@
Subproject commit 46fbd8fd067c497a740594a1b8cc8e503fc94a8a
Subproject commit 4326327888f185e994eb7071d0b0b5edb1be2768

View File

@ -35,6 +35,10 @@ export default {
})
: icon;
},
handleChange(activeKey) {
this.$emit('update:activeKey', activeKey);
this.$emit('change', activeKey);
},
},
render() {
const { prefixCls: customizePrefixCls, bordered, expandIconPosition } = this;
@ -52,6 +56,8 @@ export default {
expandIcon: panelProps => this.renderExpandIcon(panelProps, prefixCls),
class: collapseClassName,
...restAttrs,
onChange: this.handleChange,
'onUpdate:change': undefined,
};
return <VcCollapse {...rcCollapeProps}>{getSlot(this)}</VcCollapse>;

View File

@ -117,9 +117,10 @@ export default {
return newChildren;
},
setActiveKey(activeKey) {
this.setState({ stateActiveKey: activeKey });
if (!hasProp(this, 'activeKey')) {
this.setState({ stateActiveKey: activeKey });
}
this.__emit('change', this.accordion ? activeKey[0] : activeKey);
this.__emit('update:activeKey', this.accordion ? activeKey[0] : activeKey);
},
},
render() {

View File

@ -18,6 +18,8 @@ const collapseProps = () => ({
expandIcon: PropTypes.func,
openAnimation: PropTypes.object,
expandIconPosition: PropTypes.oneOf(['left', 'right']),
'onUpdate:change': PropTypes.func,
onChange: PropTypes.func,
});
const panelProps = () => ({

View File

@ -4,7 +4,7 @@
</div>
</template>
<script>
import demo from '../antdv-demo/docs/checkbox/demo/basic';
import demo from '../antdv-demo/docs/collapse/demo/index';
export default {
components: {