ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

Select custom default value

Open DaveDev13 opened this issue 1 year ago • 2 comments
trafficstars

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.1.0

Environment

Vue 3.2.47

Reproduction link

Edit on CodeSandbox

Steps to reproduce

See the link

What is expected?

I will see the first item as selected by default

What is actually happening?

See the link


The value specified in formData.organizations should be displayed as the first selected element in the selector

I thought that the values specified in :options would be compared with the values specified in v-model:value, in fact this is what happens, but the data specified in :field-names="{ label: 'name', value: 'id' }" do not affect the first selected item by default

DaveDev13 avatar Jan 18 '24 03:01 DaveDev13

need to set formData.organizations=['1'] because v-model:value just bind selected value

qppq54s avatar Jan 27 '24 02:01 qppq54s

необходимо установить formData.organizations=['1'], потому что v-model:value просто привязывает выбранное значение

Thanks for the answer, it really works. But then I don't understand what are the label-in-value and field-names properties needed for? I'll explain the case, I want to get data from the backend in the { id: "1", name: "First" } format, and just transfer them to the select, without doing unnecessary manipulation to transform the data, and after selecting the desired value, also give the data in the { id: "1", name: "First" } format

DaveDev13 avatar Feb 01 '24 12:02 DaveDev13

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Apr 02 '24 02:04 github-actions[bot]