ElemeFE / ElemeFE/element

[Feature Request] Set object default value using label for select

Open
#20,706 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Vue
Stars
54k
Forks
14.4k
PR merge metrics
No merged PRs in 30d

Description

### Existing Component
Yes

### Component Name
el-select

### Description
I have an object that I want to set as default value for el-select.

There is a prop "value-key" that determines which field from the object to treat as a key. But it's also used as a label in this case.

How to set a "value-label" so the select's input displays custom label rather then the value of the key?

I use the below "hack" which is not really reliable:

this.$nextTick(() => {
let label = object[this.labelKey]
let elem = this.$refs.selectElem
elem.selectedLabel = label
})

What is the correct way to accomplish that?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.