mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-10-31 03:22:08 +08:00 
			
		
		
		
	fix(Picker): setColumnValues failed in cascade mode (#6080)
This commit is contained in:
		
							parent
							
								
									e95e09764a
								
							
						
					
					
						commit
						2abc2f939e
					
				| @ -1,5 +1,5 @@ | |||||||
| // Utils
 | // Utils
 | ||||||
| import { createNamespace } from '../utils'; | import { createNamespace, isObject } from '../utils'; | ||||||
| import { preventDefault } from '../utils/dom/event'; | import { preventDefault } from '../utils/dom/event'; | ||||||
| import { BORDER_TOP_BOTTOM, BORDER_UNSET_TOP_BOTTOM } from '../utils/constant'; | import { BORDER_TOP_BOTTOM, BORDER_UNSET_TOP_BOTTOM } from '../utils/constant'; | ||||||
| import { pickerProps } from './shared'; | import { pickerProps } from './shared'; | ||||||
| @ -111,14 +111,9 @@ export default createComponent({ | |||||||
|         cursor = cursor.children[indexes[i]]; |         cursor = cursor.children[indexes[i]]; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       while (cursor.children) { |       while (cursor && cursor.children) { | ||||||
|         columnIndex++; |         columnIndex++; | ||||||
| 
 |         this.setColumnValues(columnIndex, cursor.children); | ||||||
|         this.setColumnValues( |  | ||||||
|           columnIndex, |  | ||||||
|           cursor.children.map((item) => item[this.valueKey]) |  | ||||||
|         ); |  | ||||||
| 
 |  | ||||||
|         cursor = cursor.children[cursor.defaultIndex || 0]; |         cursor = cursor.children[cursor.defaultIndex || 0]; | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
| @ -198,8 +193,15 @@ export default createComponent({ | |||||||
|       const column = this.children[index]; |       const column = this.children[index]; | ||||||
| 
 | 
 | ||||||
|       if (column) { |       if (column) { | ||||||
|  |         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); |           column.setOptions(options); | ||||||
|         } |         } | ||||||
|  |       } | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     // @exposed-api
 |     // @exposed-api
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user