diff --git a/src/picker/index.js b/src/picker/index.js index b2544950c..6e0f3f30e 100644 --- a/src/picker/index.js +++ b/src/picker/index.js @@ -1,5 +1,5 @@ // Utils -import { createNamespace } from '../utils'; +import { createNamespace, isObject } from '../utils'; import { preventDefault } from '../utils/dom/event'; import { BORDER_TOP_BOTTOM, BORDER_UNSET_TOP_BOTTOM } from '../utils/constant'; import { pickerProps } from './shared'; @@ -111,14 +111,9 @@ export default createComponent({ cursor = cursor.children[indexes[i]]; } - while (cursor.children) { + while (cursor && cursor.children) { columnIndex++; - - this.setColumnValues( - columnIndex, - cursor.children.map((item) => item[this.valueKey]) - ); - + this.setColumnValues(columnIndex, cursor.children); cursor = cursor.children[cursor.defaultIndex || 0]; } }, @@ -198,7 +193,14 @@ export default createComponent({ const column = this.children[index]; if (column) { - column.setOptions(options); + if (this.dataType === 'cascade') { + // map should be removed in next major version + column.setOptions( + options.map((item) => (isObject(item) ? item[this.valueKey] : item)) + ); + } else { + column.setOptions(options); + } } },