Skip to content

Commit 7da570f

Browse files
committed
refactor(vc-collapse): key support number type vueComponent#4405
1 parent f35bafb commit 7da570f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/vc-collapse/src/Collapse.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { defineComponent } from 'vue';
1515
function _toArray(activeKey) {
1616
let currentActiveKey = activeKey;
1717
if (!Array.isArray(currentActiveKey)) {
18-
currentActiveKey = currentActiveKey ? [currentActiveKey] : [];
18+
const activeKeyType = typeof currentActiveKey;
19+
currentActiveKey =
20+
activeKeyType === 'number' || activeKeyType === 'string' ? [currentActiveKey] : [];
1921
}
2022
return currentActiveKey.map(key => String(key));
2123
}
@@ -76,7 +78,7 @@ export default defineComponent({
7678
const { prefixCls, accordion, destroyInactivePanel, expandIcon } = this.$props;
7779

7880
// If there is no key provide, use the panel order as default key
79-
const key = child.key || String(index);
81+
const key = String(child.key) || String(index);
8082
const { header, headerClass, disabled } = getPropsData(child);
8183
let isActive = false;
8284

0 commit comments

Comments
 (0)