[improvement] Collapse: log tips for incorrect value (#4122)

This commit is contained in:
neverland
2019-08-15 17:50:04 +08:00
committed by GitHub
parent b06cfabe8c
commit 2dc4ab147d
2 changed files with 43 additions and 19 deletions
+8 -2
View File
@@ -38,8 +38,14 @@ export default createComponent({
return null;
}
const { value } = this.parent;
return this.parent.accordion
const { value, accordion } = this.parent;
if (process.env.NODE_ENV !== 'production' && !accordion && !Array.isArray(value)) {
console.error('[Vant] Collapse: type of prop "value" should be Array');
return;
}
return accordion
? value === this.currentName
: value.some(name => name === this.currentName);
}