File tree 4 files changed +11
-3
lines changed
4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -396,6 +396,13 @@ function isValidElement(element) {
396
396
function getPropsSlot ( slots , props , prop = 'default' ) {
397
397
return props [ prop ] ?? slots [ prop ] ?. ( ) ;
398
398
}
399
+
400
+ export const getTextFromElement = ele => {
401
+ if ( isValidElement ( ele ) && isStringElement ( ele [ 0 ] ) ) {
402
+ return ele [ 0 ] . children ;
403
+ }
404
+ return ele ;
405
+ } ;
399
406
export {
400
407
splitAttrs ,
401
408
hasProp ,
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ Select component to select value from options.
45
45
| mode | Set mode of Select | 'multiple' \| 'tags' | - | |
46
46
| notFoundContent | Specify content to show when no result matches.. | string\| slot | 'Not Found' | |
47
47
| optionFilterProp | Which prop value of option will be used for filter if filterOption is true | string | value | |
48
- | optionLabelProp | Which prop value of option will render as content of select. | string | ` value ` for ` combobox ` , ` children ` for other modes | |
48
+ | optionLabelProp | Which prop value of option will render as content of select. | string | ` children ` \| ` label ` (when use options) | |
49
49
| placeholder | Placeholder of select | string\| slot | - | |
50
50
| showSearch | Whether show search input in single mode. | boolean | false | |
51
51
| showArrow | Whether to show the drop-down arrow | boolean | true | |
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/_0XzgOis7/Select.svg
46
46
| mode | 设置 Select 的模式为多选或标签 | 'multiple' \| 'tags' \| 'combobox' | - | |
47
47
| notFoundContent | 当下拉列表为空时显示的内容 | string\| slot | 'Not Found' | |
48
48
| optionFilterProp | 搜索时过滤对应的 option 属性,不支持 children | string | value | |
49
- | optionLabelProp | 回填到选择框的 Option 的属性值,默认是 Option 的子元素。比如在子元素需要高亮效果时,此值可以设为 ` value ` 。 | string | ` children ` (combobox 模式下为 ` value ` ) | |
49
+ | optionLabelProp | 回填到选择框的 Option 的属性值,默认是 Option 的子元素。比如在子元素需要高亮效果时,此值可以设为 ` value ` 。 | string | ` children ` \| ` label ` (设置 options 时) | |
50
50
| placeholder | 选择框默认文字 | string\| slot | - | |
51
51
| showSearch | 使单选模式可搜索 | boolean | false | |
52
52
| showArrow | 是否显示下拉小箭头 | boolean | true | |
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ import createRef from '../_util/createRef';
53
53
import PropTypes from '../_util/vue-types' ;
54
54
import warning from '../_util/warning' ;
55
55
import isMobile from '../vc-util/isMobile' ;
56
+ import { getTextFromElement } from '../_util/props-util' ;
56
57
57
58
const DEFAULT_OMIT_PROPS = [
58
59
'children' ,
@@ -699,7 +700,7 @@ export default function generateSelector<
699
700
patchRawValues = patchLabels
700
701
. map ( label => {
701
702
const item = mergedFlattenOptions . value . find (
702
- ( { data } ) => data [ mergedOptionLabelProp . value ] === label ,
703
+ ( { data } ) => getTextFromElement ( data [ mergedOptionLabelProp . value ] ) === label ,
703
704
) ;
704
705
return item ? item . data . value : null ;
705
706
} )
You can’t perform that action at this time.
0 commit comments